for loop Instead of brackets you can use : and endfor;, to make a loop much easier to see within HTML code foreach loop Same, but the end keyword is endforeach; while loop Same, but the end keyword is endwhile;
All posts by
Global members of a class
Defining static members Accessing outside of the class
Inheritance of a class
Create a class that inherits from a parent class Define a class that inherits from another Now, objects of class MyChildClass can call MyChildFunction(), but objects of MyParentClass can’t. Overriding functions in a parent class Protected members Members (variables, functions, etc) can be defined with one of the following protection levels:
Create a new class
Define the class Use the class Constructor The constructor function is optional, if defined it is automatically called when an object is instantiated.
Using regex in PHP
preg_match() Does input string match regex expression preg_replace() Replace any characters that don’t match the regex expression with character from another string. You can make the replacement string empty to simply remove unwanted characters Remove all characters that are not numbers example
Regex examples
North American telephone number Test for 10-digit North American telephone numbers. Will allow spaces, hyphens, or periods as optional separators as well as optional parentheses around the first three numbers
Input – Int
Example PHP HTML
.Regex
Regular expressions operate by moving character by character, from left to right, through a piece of text. When regex finds a character that matches the first piece of the expression, it looks to find a continuous sequence of matching characters. Match text abc Match the string “abc” Alternation abc|def Match the string “abc” OR “def”Note […]
Key => Value Arrays
Key & Value Arrays or create like this Accessing array keys and values Remove Array Value
Divide
intdiv() – return the integer portion of a division