PHP Basics Flashcards
What are the different opening and closing tags for PHP?
{?php //standard tags, always available ?}
{? //short open tags (need short_open_tag enabled in php.ini, or configured with –enable-short-tags option)
{?= ?}//short echo tags (enabled by default since php 5.4, regardless of short_open_tag php.ini setting, equal to {?php echo …})
{% %}, {%= //asp tags (need asp_tags enabled in php.ini) //case insensitive, always available
script tag: {script language=”php”}
How should large blocks of text be outputted in PHP?
By dropping out of parsing mode. It’s generally more efficient than sending all of the text through echo or print.
What opening and closing tags should you use if you are embedding PHP within HMTL or XHTML?
The standard tags must be used to remain compliant with standards.
Why are short opening and closing PHP tags not recommended?
They’re not as portable, because they may not be supported on the target server.
Can the {?php opening tag be the only thing in a file?
Yes, provided there are one or more whitespace characters after the opening tag.
Do you need a semicolon terminating the last line of a PHP block?
No. The closing tag of a block automatically implies a semicolon.
Does a closing tag for a block include an immediately trailing newline?
Yes, if one is present.
What are the advantages of omitting the PHP closing tag?
-When using include or require, so unwanted whitespace will not occur at the end of files, and you will still be able to add headers to the response later.
What type of comments does PHP support?
- One-line C++ style: //
- Multi-line C style: /* */
- Unix shell style: #
When do one-line comment styles terminate?
At the end of the line or the current block of PHP code, whichever comes first. The one exception is {script} tags, which do not break out of PHP mode in a one-line comment.
Can you nest C-style comments?
No.