PHP exists as a tag inside an HTML file. Like all HTML tags, it begins with a less-than symbol, or opening angle bracket (<) and ends with a greater than symbol, or closing angle bracket (>). To distinguish it from other tags, the PHP tag has a question mark (?) following the opening angle bracket and preceding the closing angle bracket. All text outside the PHP tag is simply passed through to the browser. Text inside the tag is expected to be PHP code and is parsed.
Listing shows an ordinary HTMLpage with one remarkable difference: the PHP code between the <? and the ?>. When this page is passed through the PHP module, it will replace the PHP code with today's date. It might read something like, Friday May 1, 1999.
Listing Printing Today's Date
Whitespace, that is spaces, tabs, and carriage returns, is ignored by PHP. Used judiciously, it can enhance the readability of your code.is functionally the same as the previous example, though you may notice more easily that it contains PHP code.
Listing Reformatting for Readability<HTML>
You may also notice that in Listing there is a line of code that begins with a slash followed by an asterisk. This is a comment. Everything between the /* and the */ is equivalent to hitespace. It is ignored. Comments can be used to document how your code works. Even if you maintain your own code you will find comments necessary for all but simple scripts.
In addition to the opening and closing comment statements, PHP provides two ways to build a single-line comment. Double-slashes or a pound sign will cause everything after them to the end of the line to be ignored by the parser.
After skipping over the whitespace and the comment in Listing , the PHP parser encounters the first word: print. This is one of PHP's functions. A function collects code into a unit you may invoke with its name. The print function sends text to the browser. The contents of the arentheses will be evaluated, and if it produces output, print will pass it along to the browser.
The string of characters beginning and ending with double quotes is called a string constant or string literal. PHP knows that when quotes surround characters you intend them to be treated as text. Without the quotes, PHP will assume you are naming a function or some other part of the language itself. In other words, the first quote is telling PHP to keep hands off until it finds another quote.
Notice that print is typed completely in lowercase letters, yet date has a leading uppercase letter. I did this to illustrate that PHP takes a very lenient attitude toward the names of its built-in functions. Print, PRINT, and PrInT are all valid calls to the same function. However, for the sake of readability, it is customary to write PHP's built-in functions sing lowercase letters only.
PHP Related Interview Questions
|PHP Interview Questions||MySQL Interview Questions|
|PHP+MySQL Interview Questions||Drupal Interview Questions|
|MYSQL DBA Interview Questions||PHP5 Interview Questions|
|WordPress Interview Questions||Joomla Interview Questions|
|CakePHP Interview Questions||CodeIgniter Interview Questions|
|PHP7 Interview Questions|
An Introduction To Php
Variables, Operators, And Expressions
Classes And Objects
I/o And Disk Access
Time, Date, And Configuration Functions
Parsing And String Evaluation
Sorting Searching And Random Numbers
Integration With Html
Efficiency And Debugging
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.