PHP also stores all global variables in an array called $GLOBALS[index]. The index holds the name of the variable. This array is also accessible from within functions and can be used to update global variables directly.
The example above can be rewritten like this: Example
$txt1 = "hello world" echo "
"; // prints out the h2 heading with set textprint similar to echo, differences: echo is minimally faster, takes multiple arguments and does not return a value print can take one argument and returns 1
var_dump($x); - returns type and value of variable
$cars = array("Volvo","BMW","Toyota");
color = $color; $this->model = $model; } public function message() { return "My car is a " . $this->color . " " . $this->model . "!"; } } $myCar = new Car("black", "Volvo"); echo $myCar -> message(); echo ""; $myCar = new Car("red", "Toyota"); echo $myCar -> message(); ?>
The PHP strlen() function returns the length of a string. str_word_count() strrev() The PHP strpos() function searches for a specific text within a string. If a match is found, the function returns the character position of the first match. If no match is found, it will return FALSE. echo str_replace("world", "Dolly", "Hello world!"); // outputs Hello Dolly!
is_int() is_integer() - alias of is_int() is_long() - alias of is_int()
is_float() is_double() - alias of is_float()
is_finite() is_infinite()
is_nan()
/ Check if the variable is numeric
$x = 5985;
var_dump(is_numeric($x));
echo "
";
$x = "5985"; var_dump(is_numeric($x));
echo "
";
$x = "59.85" + 100; var_dump(is_numeric($x));
echo "
";
$x = "Hello"; var_dump(is_numeric($x));
- post sends data without putting it in the url (secure) method = "get" - get sends data and includes it in the url(insecure)how to acces variables from forms $_GET["var_name"] / $_POST["var_name"]
trim() stripslashes()