PHP docs
| Id/Actions | Category | Code Examples | Test Code | Links | Remarks |
|---|---|---|---|---|---|
| 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) { } |
||
| 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 |
||
| 6 View |
2 special types | <?php // 1. resource type: /** A resource is a special variable, holding a reference to an external resource. Resources are created and used by special functions. See the appendix for a listing of all these functions and the corresponding resource types. */ // 2. NULL type: $var = NULL; echo "null == " . $var; |
null == | ||
| 10 View |
boolean | <?php var_dump((bool) ""); // bool(false) var_dump((bool) 1); // bool(true) var_dump((bool) -2); // bool(true) var_dump((bool) "foo"); // bool(true) var_dump((bool) 2.3e5); // bool(true) var_dump((bool) array(12)); // bool(true) var_dump((bool) array()); // bool(false) var_dump((bool) "false"); // bool(true) |
bool(false) bool(true) bool(true) bool(true) bool(true) bool(true) bool(false) bool(true) | http://www.php.net/manual/en/language.types.boolean.php | |
| 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) |
Page 1 of 10, showing 5 records out of 46 total, starting on record 1, ending on 5
