PHP TutorialphpUncle .
The PHP Hypertext Preprocessor (PHP) is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications. This tutorial helps you to build your base with PHP.
PHP started out as a small open source project that evolved as more and more people found out how useful it was. Rasmus Lerdorf unleashed the first version of PHP way back in 1994.
PHP code is written inside php code tags
Every PHP command ends with a semi-colon (;)
PHP files are saved with the “.php” file extension
<?php echo "Hello PHP!"; ?>
A PHP comment is a string of code or text that is not visible in your web browser. Main purpose of comments is to serve as a note to you.
PHP supports two types of comment-
- Single-Line Comment
- Multi-Line Comment
Single-Line Comment is used for only one line and writing small notes.
<?php //This is a single-line comment; ?>
Multi-Line Comment is used for large block and writing multiple lines notes.
<?php /* This is a multi-lines comment block that hides multiple lines */ ?>
- Variables are used to store both numeric and non-numeric data
- PHP variables starts with a dollar($) sign, followed by the name of the variable
- PHP automatically converts the variable to the correct data type, depending on its value
- A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
- The variable name must begin with a letter or the underscore character
- A variable name cannot start with a number
- A variable name should not contain space
<?php // Declaring variables $text = "Phpuncle PHP Tutorial!"; $number = 50; // Displaying variables value echo $text; // Output: Phpuncle PHP Tutorial! echo $number; // Output: 50 ?>