PHP docs
| Id/Actions | Category | Code Examples | Test Code | Links | Remarks |
|---|---|---|---|---|---|
| 1 View |
check what browser the user is accessing your web server | <?php
echo $_SERVER['HTTP_USER_AGENT'];
?>
|
CCBot/1.0 (+http://www.commoncrawl.org/bot.html) | ||
| 2 View |
closing tag ?> can be omitted | <?php echo 'We omitted the last closing tag'; |
We omitted the last closing tag | ||
| 3 View |
Three types of comments | <?php
// This is a one-line c++ style comment
/* This is a multi line comment
yet another line of comment */
echo 'A Test'; # A shell-style comment
|
A Test | ||
| 4 View |
2 scalar types | <?php // 4 scalar types: // 1. boolean: $bar = true; echo "a boolean bar == " . $bar . "<br>"; // 2. integer: $anInt = 8; echo "anInt == " . $anInt . "<br>"; // 3. float: $aFloat = 3.14159; echo "aFloat scalar == " . $aFloat . "<br>"; // 4. string: $aString = "Hello World"; echo "aString scalar == " . $aString . "<br>"; |
a boolean bar == 1 anInt == 8 aFloat scalar == 3.14159 aString scalar == Hello World |
||
| 5 View |
2 compound types | <?php
// 1. array:
$arr = array("foo" => "bar", 12 => true);
echo "arr[foo] == " . $arr["foo"] . "<br>"; // bar
echo "arr[12] == " . $arr[12] . "<br>"; // 1
print_r($arr);
// 2. object type:
class foo
{
function do_foo()
{
echo "Doing foo. <br>";
}
}
$bar = new foo;
$bar->do_foo();
print_r($bar);
print("<br>");
var_dump($bar);
|
arr[foo] == bar arr[12] == 1 Array ( [foo] => bar [12] => 1 ) Doing foo. foo Object ( ) object(foo)#140 (0) { } |
Page 1 of 10, showing 5 records out of 46 total, starting on record 1, ending on 5
