Variables

You can also easily intertwine small segments of PHP into HTML, such as when printing out the value of a variable:

<h1>Today's Date is <?= $date ?>.</h1> 

The “<?=” syntax in the php, when followed by a variable, is used as shorthand for the echo() function.

You can include comments in your PHP scripts. Comments are ignored by the Web server, and any comments contained within the PHP code are not sent to a browser. There are three forms of comments:

  • #— Used just like it is used in PERL; comments out the remainder of the line after the # symbol.

  • //— Used just like it is in JavaScript; comments out the remainder of the line after the // symbols.

  • /* and */ Comments out anything in between the two sets of symbols. This is the same syntax ...

Get Advanced PHP for Web Professionals now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.