echo function is used to display or print output
This is a single-line comment
This is a single-line comment
This is a multiline comment
This function dumps information about one or more variables.
Variables are "containers" for storing information.
Datatype is a type of data
A string is a sequence of characters, like "Hello world!".
An integer is a number without any decimal part.
A float is a number with a decimal point or a number in exponential form.
An array stores multiple values in one single variable
A class is a template for objects
An object is an instance of the class.
Escape sequences are used for escaping a character during string parsing. They are also used for giving special meaning to represent line breaks, tabs, alerts, and more.
It adds a newline
It inserts a carriage return in the text at this point.
It gives a horizontal tab space
It gives a vertical tab space
It is used for escape characters
It is commonly used as page separators but now is also used as section separators.
It adds a backslash
Print the next character as a dollar, not as part of a variable
Print the next character as a single quote, not a string closer
Print the next character as a double quote, not a string closer
Operators are symbols that tell the compiler or interpreter to perform specific mathematical or logical manipulations. These are of several types.
Sum of $x and $y
Difference of $x and $y
Product of $x and $y
Quotient of $x and $y
The remainder of $x divided by $y
Result of raising $x to the $y'th power
The left operand gets set to the value of the expression on the right
x += y (Equivalent to x = x + y)
x -= y (Equivalent to x = x - y)
x *= y (Equivalent to x = x * y)
x /= y (Equivalent to x = x / y)
x %= y (Equivalent to x = x % y)
Returns true if $x is equal to $y
Returns true if $x is equal to $y, and they are of the same type
Returns true if $x is not equal to $y
Returns true if $x is not equal to $y
Returns true if $x is not equal to $y, or they are not of the same type
Returns true if $x is greater than $y
Returns true if $x is less than $y
Returns true if $x is greater than or equal to $y
Returns true if $x is less than or equal to $y
Increments $x by one, then returns $x
Returns $x, then increments $x by one
Decrements $x by one, then returns $x
Returns $x, then decrements $x by one
True if both $x and $y are true
True if either $x or $y is true
True if either $x or $y is true, but not both
True if both $x and $y are true
True if either $x or $y is true
True if $x is not true
Concatenation of $txt1 and $txt2
Appends $txt2 to $txt1
Union of $x and $y
Returns true if $x and $y have the same key/value pairs
Returns true if $x and $y have the same key/value pairs in the same order and of the same types
Returns true if $x is not equal to $y
Returns true if $x is not equal to $y
Returns true if $x is not identical to $y
Returns the value of $x. The value of $x is expr2 if expr1 = TRUE. The value of $x is expr3 if expr1 = FALSE
if statement checks the condition and if it is True, then the block of if statement executes; otherwise, control skips that block of code.
If the condition of the if block evaluates to True, then the if block executes; otherwise, the else block executes.
It executes different codes for more than two conditions.
It allows a variable to be tested for equality against a list of values (cases).
It is used to iterate the statements several times. It is frequently used to traverse the data structures like the array and linked list.
The foreach loop loops through a block of code for each element in an array.
It iterates the block of code as long as a specified condition is True or vice versa.
This loop is very similar to the while loop with one difference, i.e., the body of the do-while loop is executed at least once even if the condition is False. It is an exit-controlled loop.
$GLOBALS is a PHP super global variable used to access global variables from anywhere in the PHP script.
Returns the filename of the currently executing script. $_SERVER is a PHP super global variable which holds information about headers, paths, and script locations.
Returns the version of the Common Gateway Interface (CGI) the server is using
Returns the IP address of the host server
Returns the name of the host server (such as www.codewithharry.com)
Returns the server identification string (such as Apache/2.2.24)
Returns the name and revision of the information protocol (such as HTTP/1.1)
Returns the request method used to access the page (such as POST)
Returns the timestamp of the start of the request (such as 1377687496)
Returns the query string if the page is accessed via a query string
Returns the Accept header from the current request
Returns the Accept_Charset header from the current request (such as utf-8,ISO-8859-1)
Returns the Host header from the current request
Returns the complete URL of the current page (not reliable because not all user-agents support it)
Is the script queried through a secure HTTP protocol?
Returns the IP address from where the user is viewing the current page
Returns the Hostname from where the user is viewing the current page
Returns the port being used on the user's machine to communicate with the web server
Returns the absolute pathname of the currently executing script
Returns the value given to the SERVER_ADMIN directive in the web server configuration file (if your script runs on a virtual host, it will be the value defined for that virtual host) (such as someone@codewithharry.com)
Returns the port on the server machine being used by the webserver for communication (such as 80)
Returns the server version and virtual hostname which are added to server-generated pages
Returns the file system based path to the current script
Returns the path of the current script
Returns the URI of the current page
PHP $_GET is a PHP super global variable used to collect form data after submitting an HTML form with method="get".
PHP $_POST is a PHP super global variable used to collect form data after submitting an HTML form with method="post". $_POST is also widely used to pass variables.
PHP $_REQUEST is a PHP super global variable used to collect data after submitting an HTML form.
Boolval is used to get the boolean value of a variable
It is used to check whether a variable is empty. It also checks whether the variable is set/declared:
It unsets variables.
debug_zval_dump is used to dump a string representation of an internal zval structure to output
Empty is used to check whether a variable is empty or not.
It returns the float value of different variables:
It returns all defined variables, as an array:
It returns the resource type:
It returns the type of different variables:
It returns the integer value of different variables:
To check whether a variable is an array or not:
An array stores multiple values in one single variable.
A function is a block of statements that can be used repeatedly in a program.
It opens a non-persistent MySQL connection
It returns the number of affected rows
It shows the Error description for the connection error
It fetches all result rows as an array
It fetches a result row as an associative, a numeric array, or both
It fetches a result row as an associative array
It fetches one row from a result set and returns it as an enumerated array
It kills a MySQL thread
It closes a database connection