Tuesday, July 3, 2012

Find if url(current address) contains "?" or not with php

//  how to find the current url contains  the "?" or not
// to verify the current url has the one/single query string variable or many  string variable
function  get_urlsigntype($current_url) {
    if(strpos($current_url, '?') === false) {
        return "?";
    } else {
        return "&";
    }
}

Monday, July 2, 2012

How to get client's IP address with PHP

<?php
//  get the  client ip address and store into the variable.

$client_ipaddress = $_SERVER["REMOTE_ADDR"];
echo "Client IP is :".$client_ipaddress;
?>

Get Current file Name in php

<?php

//  get the current file name
$currentFile_Name = $_SERVER["SCRIPT_NAME"];
echo basename($currentFile_Name); 
 
?>

Comments in PHP

1. Single Line Comment

<?php
 //here is any code
//echo "this  is test";

?>



2. Multiple Line Comment

<?php
/* Here is your  code 
 
echo " this is test..."; 
echo "this is not display at screen";
*/
?>

Php tags

1.  php short tag  


<? = ?>

2. php full tag


<?php
// write your code here

?>