What is PHP:
PHP is mostly used server side scripting language which is designed for web development. It is also used as a general-purpose programming language. PHP originally stands for Personal Home Page but it now stands for the recursive acronym Hypertext Preprocessor. Rasmus Lerdorf created in 1994 and now the PHP reference implementation is produced by PHP Development Team. PHP code can either be embedded into HTML or HTML5 markup, or it can be used along with various web frameworks, web CMS (Content Management Systems), web template systems.
PHP code is processed by a PHP interpreted implemented as a module in the web server or as a CGI (Common Gateway Interface) executable. The web server software combines the results which are interpreted and executed PHP code, which may be any type of data, including images, with the generated web page. PHP code may also be executed with a command line interface (CLI) and can be used to implement standalone graphical applications.
Some features of PHP are given below:
1.It is open source and very simple.
2.It is faster than any other scripting language.
3.It is an interpreted language (no need of compilation).
4.PHP is platform independent i.e., code will run on every platform.
Basic PHP Syntax:
Steps for writing a PHP Syntax are as follows:
1.Create a blank file using any program that can save in plain text format.
2.Save your file name as a .PHP file. Saving a page with the .php extension tells your server it needs to execute the PHP code.
3.Enter the statement to let the server know that there is PHP code coming up.
4.After this, we should enter the body of PHP program.
5.At last enter ?> to let the browser know that the PHP code is done.
Each and Every section of PHP code starts and ends by turning on and off PHP tags, to make the server know that it needs to execute the PHP code in between them. Here is an example:
Everything in between these tags is read as PHP Code.Anything outside of these PHP tags is treated as HTML Code.So,you can easily switch between PHP and HTML as needed.
If you want to make a note to yourself of what the code is about for reference to edit it later, you can use Comments.
Some ways for creating comments in PHP are as follows:
//A comment on a single line
#Another type of comment on a single line
/*Multiple line comment */
Print and Echo statements:
Print and echo are two basic ways to get output in PHP. Both are almost the same, the difference is ECHO is slightly faster than PRINT.
echo ”It is PHP code”
print ”It is PHP code”
A variable is something that represents another value. In PHP, a variable starts with the $ sign, followed by the name of the variable.
- $txt =”Hello World!”
You can learn complete PHP from Bytes Online Training with real time experienced trainers. Training in your flexible timings,24*7 support team, trainers with minimum 3 years of real time experience in the industry. Bytes Online Training provides FREE Live Demo for everyone.