Breaking News
Home / Web / PHP (page 4)

PHP

Array Push/Pop Functions in PHP

Array functions like array_push and array_pop can be used to add or elements to the end of array respectively. <?php $stack = array("orange", "banana"); array_push($stack, "apple", "raspberry"); print_r($stack); ?> //The above example will output:   Array (     [0] => orange     [1] => banana     [2] …

Read More »

What are the most common Mysql Commands used in PHP?

Answer PHP provides very simple commands to connect, fetch or execute query against MYSQL database. The following are as common commands.    * mysql_connect(). Opens a connection to the MYSQL server. The input to this command is the database     hostname, username, and password.    * mysql_select_db(). Selects a database on …

Read More »

What are the various gobal variables in PHP?

Answer PHP provides a variety of Globals which are exposed as associative array in the scripts are as follows: $_GET[‘variable_name’]– To access data stored in html form fields when form post method “GET”. $_POST[‘variable_name’]– To access data stored in html form fields when form post method “POST”. $_REQUEST[‘variable_name’]– To access …

Read More »

How to resolve Hostname to IP or viceversa in PHP?

PHP language provides two convenient functions to achieve this. – gethostbyaddr() -gethostbyname() The gethostbyaddr() and gethostbyname() functions will return the hostname or IP address of a given machine, respectively. The syntax of these function is as follows gethostbyaddr(“IP Address”); gethostbyname(“hostname”); <?php   // set iP address $ip = "74.125.224.147";   …

Read More »