Genius way for easy installation and Know of PHP syntax and Comment.
Installation (requirements and How to install)
To start using (coding) PHP For the first and most common form, you need three things:
- PHP itself
- a web server
- a web browser
SETUP PHP: Hypertext Preprocessor ON YOUR COMPUTER
You probably already have a web browser, and depending on your operating system setup, you may also have a web server (e.g. Apache on Linux and macOS; IIS on Windows).
For PHP Installation support visit http://php.net/manual/en/install.php the Official website of PHP
SETUP PHP: Hypertext Preprocessor ON HOSTED WEBSPACE
You may also rent webspace at a company. This way, you don’t need to set up anything on your own, only write your PHP scripts, upload it to the server you rent, and see the results in your browser.
WHAT IS PHP PARSER
Software that converts source code into something more easily (and more efficiently) understandable by a computer.
When PHP parses a file, it looks for opening and closing tags, which are <?php and ?> which tell PHP to start and stop interpreting the code between them.
Parsing in this manner allows PHP to be embedded in all sorts of different documents, as everything outside of a pair of opening and closing tags is ignored by the PHP parser.
If a file contains only PHP code, it is preferable to omit the PHP closing tag at the end of the file.
Php file have extension “.php”
HOW PHP BASIC CODING LOOKS
<?php PHP code goes here ?>
Below shows #1 example of basic PHP CODES
<?php echo "Hello world"; // ... more code echo "Last statement"; // the script ends here with no PHP closing tag
Everything outside of a pair of opening and closing tags is ignored by the PHP parser which allows PHP files to have mixed content. This allows PHP to be embedded in HTML documents, for example to create templates.
#2 EXAMPLE OF PHP ESCAPING FROM HTML
<p>This is going to be ignored by PHP and displayed by the browser.</p> <?php echo 'While this is going to be parsed.'; ?> <p>This will also be ignored by PHP and displayed by the browser.</p>
The above example escapes from HTML as explained
Example #3 Advanced escaping using conditions
<?php if ($expression == true): ?> This will show if the expression is true. <?php else: ?> Otherwise this will show. <?php endif; ?>
In this example PHP will skip the blocks where the condition is not met, even though they are outside of the PHP open/close tags; PHP skips them according to the condition since the PHP interpreter will jump over blocks contained within a condition that is not met.
The closing tag of a block of PHP code automatically implies a semicolon;
you do not need to have a semicolon terminating the last line of a PHP block.
The closing tag for the block will include the immediately trailing newline if one is present.
EXAMPLE #4 Instruction separation of PHP tag
<?php echo 'This is a test'; ?> <?php echo 'This is a test' ?> <?php echo 'We omitted the last closing tag';
The closing tag of a PHP block at the end of a file is optional
PHP statements end with a semicolon (;).
A comment in PHP code is not just a line but texts that are not readable/executed as part of the program on webserver.
Why php Comment
To write a note for yourself the web developer or to others who may view your php file source and open it for edit so they may understand what you really thinking while writing the code.
We have three special characters commenting in PHP they / # *
PHP Comment are also used in two different dimension the single line commenting and the multiple line commenting
EXAMPLE #5 PHP COMMENT
<?php echo 'This is a test'; // This is a one-line c++ style comment /* This is a multi line comment yet another line of comment */ echo 'This is yet another test'; echo 'One Final Test'; # This is a one-line shell-style comment ?>
PHP supports ‘C’, ‘C++’ and Unix shell-style (Perl style) comments. As show in the example above.