Created
August 13, 2014 07:52
-
-
Save copycut/0b52f72f3e4e34c7f51a to your computer and use it in GitHub Desktop.
PHP functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TYPES | |
define("NAME", "copycut"); // const | |
$int = 1; | |
$float = 1.1; | |
$bool = true; | |
$string = "hello"; | |
$array = array(); | |
// PRINT THINGS | |
echo ... // Array | |
echo($var); // Array | |
print($var); // Array | |
print_r($var); // Array( [0] => copycut ) | |
var_dump($var); // array(1) { [0]=> string(6) "copycut" } | |
$example_ar = array("copycut", 43, 2.5, true); | |
print_r($example_ar); // Array ( [0] => didier [1] => 43 [2] => 2.5 [3] => 1 ) | |
var_dump($example_ar); // array(4) { [0]=> string(6) "copycut" [1]=> int(43) [2]=> float(2.5) [3]=> bool(true) } | |
// GET TYPES | |
gettype($int); //-> integer | |
// STRINGS | |
$hello = "hello"; | |
echo $hello; //-> print hello (without quotes) | |
echo $hello{0}; //-> print h | |
// ARRAYS | |
$ar = array("name", "age", "birthday"); // example | |
$ar2 = array(42, "green", 3.14, true); // mix data types | |
echo $ar[0]; //-> print name | |
$ar[0] = "fitst_name"; //-> modify value | |
$ar[] = "location"; //-> push a item in the array end | |
// CHECKS | |
echo(true === TRUE); // 1 | |
var_dump(true === TRUE) // bool(true) | |
var_dump($var) // explode var | |
var_dump((bool) $var) // return true or flase | |
isset($var) // return true or false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment