Php examples with source code
- php script should start with
- php script should start with and end with
- php if starts with
- php scripts starts with
Php code examples with output
Php code in html!
The PHP script can be embedded within HTML web pages. The script starts with and ends with .
Note that when dealing with pure PHP files, the closing tag () is not required. It is only required when the PHP script is embedded in an HTML document.
Below is a very typical example of a simple code written in PHP.
The script uses the function, which simply displays text on a web page:
Note that PHP statements end with a semicolon ().
PHP Comments
A comment is just text that the PHP engine ignores.
Which of the following is not a valid php codeThe objective of comments is to make the code easier to read. It may aid another developer (or you in the future when you modify the source code) in understanding what you were attempting to do using PHP.
PHP support single-line as well as multi-line comments.
To write a single-line comment either start the line with either two slashes () or a hash symbol ().
For multi-line comments, start the comment with a slash followed by an asterisk () and end the comment with an asterisk followed by a slash ():
Case Sensitivity
Variable names in PHP are case-sensitive.
As a result the variabl
- php script start and end with