php variable substitution/expansion
We know that a variable will be substituted with its value in a “” delimited string such as: $var1=”var1″; echo “this is $var1”; will print “this is var1”. This variable […]
We know that a variable will be substituted with its value in a “” delimited string such as: $var1=”var1″; echo “this is $var1”; will print “this is var1”. This variable […]
I had a case to use regexp to match unicode codes of chinese characters. The unicode codes are of the form \uxxxx where x is hexidecimal digit. To match them, […]
In a php file, you can define a string using ” ” or ‘ ‘. You specify what characters the string consists of in between ‘ ‘ or ” “such […]
The return value of explode function is obvious in most cases, for example: $ar=explode(“\n”,”a\nb”) return an array that has two elements: $ar[0]=’a’,$ar[1]=’b’; But sometimes the return value may cause confusion. […]
$timestamp=gmmktime(22,50,0,2,10,2015); It considers Oct 10,2015,22(hour):50(minute):0(second) is the GMT time. It calculates the seconds between this time and GMT Jan 1,1970,0:0:0. $timestamp=mktime(22,50,0,2,10,2015); It looks for the time zone settings in […]
$_SERVER[‘REQUEST_URI’] is what you type in your address bar of your browse(no protocol and host part). $_SERVER[‘PHP_SELF’] is the url of the first file loaded(no protocol and host part) with […]
First, we should know that isset and empty are php language construct while is_null is a function. So you won’t get an E_NOTICE when passing undefined variable to isset or […]
php require() will die if the included file has a syntax error even the error line is not executed(i.e., within a function that is not called) for example: file1.php <?php […]
If you do not use header() in your php script, what are the default http headers your browser gets? Here are the http headers php 5.4 generates in the response: […]
Of course, you can put echo or print statements somewhere in the debugged php file to print some messages or value of variables. More convenient way is using an IDE […]