php 5 syntax
DESCRIPTION
PHP 5 SyntaxTRANSCRIPT
-
REFERENCES | EXAMPLES | FORUM | ABOUT
PHP TutorialPHP HOMEPHP IntroPHP InstallPHP SyntaxPHP VariablesPHP Echo / PrintPHP Data TypesPHP String FunctionsPHP ConstantsPHP OperatorsPHP If...Else...ElseifPHP SwitchPHP While LoopsPHP For LoopsPHP FunctionsPHP ArraysPHP Sorting ArraysPHP Superglobals
PHP FormsPHP Form HandlingPHP Form ValidationPHP Form RequiredPHP Form URL/E-mailPHP Form Complete
PHP AdvancedPHP Arrays MultiPHP Date and TimePHP IncludePHP File HandlingPHP File Open/ReadPHP File Create/WritePHP File UploadPHP CookiesPHP SessionsPHP E-mailPHP Secure E-mailPHP ErrorPHP ExceptionPHP Filter
PHP DatabasePHP MySQL IntroPHP MySQL ConnectPHP CREATE DB/TablePHP INSERT INTOPHP SELECTPHP WHEREPHP ORDER BYPHP UPDATEPHP DELETEPHP ODBC
PHP XMLXML Expat ParserXML DOMXML SimpleXML
PHP and AJAXAJAX IntroAJAX PHPAJAX DatabaseAJAX XMLAJAX Live SearchAJAX RSS ReaderAJAX Poll
PHP ExamplesPHP ExamplesPHP QuizPHP Certificate
PHP ReferencePHP ArrayPHP CalendarPHP DatePHP DirectoryPHP ErrorPHP FilesystemPHP FilterPHP FTPPHP HTTP
Previous Next Chapter
PHP 5 Syntax
The PHP script is executed on the server, and the plain HTML result is sent back to the browser.
Basic PHP SyntaxA PHP script can be placed anywhere in the document.
A PHP script starts with :
The default file extension for PHP files is ".php".
A PHP file normally contains HTML tags, and some PHP scripting code.
Below, we have an example of a simple PHP file, with a PHP script that uses a built-in PHP function "echo" to output thetext "Hello World!" on a web page:
Example
My first PHP page
Run example
Note: PHP statements are terminated by semicolon (;). The closing tag of a block of PHP code also automatically implies asemicolon (so you do not have to have a semicolon terminating the last line of a PHP block).
Comments in PHPA comment in PHP code is a line that is not read/executed as part of the program. Its only purpose is to be read bysomeone who is editing the code!
Comments are useful for:
To let others understand what you are doing - Comments let other programmers understand what you were doing ineach step (if you work in a group)To remind yourself what you did - Most programmers have experienced coming back to their own work a year or twolater and having to re-figure out what they did. Comments can remind you of what you were thinking when youwrote the code
PHP supports three ways of commenting:
Example
Run example
PHP Case SensitivityIn PHP, all user-defined functions, classes, and keywords (e.g. if, else, while, echo, etc.) are NOT case-sensitive.
In the example below, all three echo statements below are legal (and equal):
Search w3schools.com:
WEB HOSTINGBest Web Hosting
UK Reseller HostingDedicated Servers
cPanel Hosting
WEB BUILDINGXML Editor - Free Trial!FREE Website BUILDERFree HTML5 Templates
W3SCHOOLS EXAMSHTML, CSS, JavaScript,PHP, jQuery, XML, and
ASP Certifications
SHARE THIS PAGE
WEB RESOURCESWeb StatisticsWeb Validation
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
Select Language
PHP 5 Syntax 28/05/2014
http://www.w3schools.com/php/php_syntax.asp 1 / 2
-
PHP LibxmlPHP MailPHP MathPHP MiscPHP MySQLiPHP SimpleXMLPHP StringPHP XMLPHP ZipPHP Timezones
Previous Next Chapter
Example
Run example
However; in PHP, all variables are case-sensitive.
In the example below, only the first statement will display the value of the $color variable (this is because $color, $COLOR,and $coLOR are treated as three different variables):
Example
Run example
REPORT ERROR | HOME | TOP | PRINT | FORUM | ABOUT | ADVERTISE WITH US
Top 10 Tutorials
HTML Tutorial HTML5 Tutorial CSS Tutorial CSS3 Tutorial JavaScript Tutorial jQuery Tutorial SQL Tutorial PHP Tutorial ASP.NET Tutorial XML Tutorial
Top 10 References
HTML/HTML5 Reference CSS 1,2,3 Reference CSS 3 Browser Support JavaScript HTML DOM XML DOM PHP Reference jQuery Reference ASP.NET Reference HTML Colors
Top 10 Examples
HTML Examples CSS Examples JavaScript Examples HTML DOM Examples PHP Examples jQuery Examples XML Examples XML DOM Examples ASP Examples SVG Examples
Web Certificates
HTML Certificate HTML5 Certificate CSS Certificate JavaScript Certificate jQuery Certificate XML Certificate ASP Certificate PHP Certificate
Color Picker
W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examplesare constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use,
cookie and privacy policy. Copyright 1999-2014 by Refsnes Data. All Rights Reserved.
PHP 5 Syntax 28/05/2014
http://www.w3schools.com/php/php_syntax.asp 2 / 2
PHP TutorialWEB HOSTINGPHP 5 SyntaxWEB BUILDINGBasic PHP SyntaxW3SCHOOLS EXAMSPHP FormsSHARE THIS PAGEExamplePHP AdvancedPHP DatabaseComments in PHPWEB RESOURCESPHP XMLExamplePHP and AJAXPHP ExamplesPHP ReferencePHP Case SensitivityExampleExampleTop 10 TutorialsTop 10 ReferencesTop 10 ExamplesWeb CertificatesColor Picker