What is PHP?
The acronym PHP initially stood for Personal Home Page.
As of version 3, it stands for PHP Hypertext Preprocessor. It is a general purpose server side scripting language that is used to develop:
- Dynamic Websites
- Custom Web Portal (Like ERP, CRM)
- Web Applications
- E-commerce Websites (Like Flipkart, Amazon, Paytm, Snapdeal etc)
- CMS – Content Management System
Importance of PHP?
- It costs low with cost effective database applications
- It is platform independent
- PHP supports all major web servers
- The existence of multiple security layers make PHP one of the most secure options for developing the most critical websites and web applications.
- PHP supports a wide array of databases including dataBase, MySQL etc.
History of PHP
- Designed by Rasmus Lerdorf
- Developer The PHP Development Team, Zend Technologies
- First appeared June 8, 1995; 21 years ago
- Stable release 7.1.0/ December 1, 2016
Basic Structure of PHP
<?php //your code here ?>
Example:
<!doctype html> <html> <head><title>Hello World Script</title></head> <body> <?php echo "<p>Hello World!</p>"; ?> </body> </html>Printing statement in PHP
If you want to print/echo some string/variable or number in php
<?php $variable = "your string"; // echo $variable; // ?>File Extension of PHP
PHP files have the file extension .php
Comment Line in PHP
- Single Line Comments
Single line comments start with //.
Any text between // and the end of the line will be ignored by PHP(will not be executed).
Example
echo 'This is a test'; // This is a one-line c++ style comment
- Multi-line Comments
Multi-line comments start with /* and end with */.
Any text between /* and */ will be ignored by PHP.
Example
/* This is a multi line comment yet another line of comment */ /* echo 'This is yet another test'; echo 'Hi'; */ echo 'One Final Test'; # This is a one-line shell-style commentVariable Declaration
In PHP, a variable starts with the $ sign, followed by the name of the variable:
Example
<?php $Vraiable_name = "Hello world!"; $x = 5; $y = 10.5; ?>A variable can have a short name (like x and y) or a more descriptive name (age, car name, total_volume).
Rules for PHP variables:
- A variable starts with the $ sign, followed by the name of the variable
- A variable name must start with a letter or the underscore character
- A variable name cannot start with a number
- A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
- Variable names are case-sensitive ($age and $AGE are two different variables)
R for Rabbit Protector Plus Drawer Locker for Kids (1 Unit) | Premium Cabinets Door & Cupboard Lock | Wardrobe Child Safety Proofing Drawer Locks
₹152.00 (as of July 3, 2025 20:39 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Baby Nail Trimmer | New Born Essentials | Baby Nail Cutter New Born 0-12 Months with 6 Filer Heads Adjustment |1 Year Warranty |
₹299.00 (as of July 3, 2025 20:39 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)LuvLap Pant Style Baby Diapers, Large (L), 62 Count, For babies of Upto 9-14Kg with Aloe Vera Lotion for rash protection, with upto 12hr protection, Diapers
₹528.00 (as of July 3, 2025 20:39 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Mini Wonders Inflatable Water Play Mat, Baby Tummy Time Mat, Safe BPA-Free, 0-12 Months
₹179.00 (as of July 3, 2025 20:39 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)R for Rabbit Large L Size Premium Feather Diaper for Baby 9 to 14 kgs (24 Pack Offer)
₹449.00 (as of July 3, 2025 20:39 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)MamyPoko Pants Extra Absorb Baby Diapers, Large (L size) | 9-14 kg | 64 Count |Deep Sleep Diapers| Soft gentle fit |Deep Absorbent Crisscross | skin friendly with coconut oil |
₹906.00 (as of July 3, 2025 20:39 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Himalaya Powder For Baby, 700G
₹291.00 (as of July 3, 2025 20:39 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Owme Unicorn Night Lights for Girls Bedroom,16 Colors Cute Night Light for Kids, Led Rechargeable Unicorn Lamp, Unicorns Gifts for Girls Night Lamp, Silicone Night Light Kids Cute - Multicolor
₹299.00 (as of July 3, 2025 20:39 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)R for Rabbit Protector Plus Fridge Locker for Kids (Pack of 1 Unit), Child Safety Refrigerator Door Latch Protector EN71 Certified | Strong 3M Adhesive | Simple Lock- Unlock Mechanism Fridge Protective Lock for Kids - White
Now retrieving the price.
(as of July 3, 2025 20:39 GMT +05:30 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)