file extension:
.php .php3 .phtml
php block:
<?php … ?>
comment:
//comment
/*…
…
…*/
output:
echo “text”; // can omit ()
print “text”; // can omit ()
print_r(object);
var_dump(object);
gettype()
is_type function
variable:
start with $
follow by alphabet or _
can only contain alphabet, _ or number
string:
$txt1=”Hello World”;
$txt2=’1234′;
echo $txt1 . ” ” . $txt2; // Hello World 1234
echo strlen(“Hello world!”); //12
array:
array(value1[,value2])
array(key => value [,key => value])
key can be integer or string
$a1 = array(“Peter”=>32);
$a1["Peter"] //32
$a2 = array(“Peter”);
$a2[0] //”Peter”
function:
function funcName([param1[,param2]])
{
…
[return ...;]
}
stdClass
$_GET
$_POST
$_COOKIE
$_REQUEST = $_GET + $_POST + $_COOKIE
$_FILES
$_SESSION
include(“file”): if error, will continue to process, but will has warnning message
require(“file”): if error, will stop further process
exit(“exit message”);
die(“exit message”);
A or B: if A is false, execute B
set_error_handler()
trigger_error()
error_log()
set_exception_handler()
throw new Exception(“exception message”);
try
catch
mysql_connect()
mysql_pconnect()
mysql_error()
mysql_select_db()
mysql_query()
mysql_fetch_array()
mysql_close()
odbc_connect()
odbc_exec()
odbc_fetch_row()
odbc_result()
odbc_close()
array_key_exists()
property_exists()
get_class()
$this->
self::
parent::