Vinod Sebastian – B.Tech, M.Com, PGCBM, PGCPM, PGDBIO

Hi I'm a Web Architect by Profession and an Artist by nature. I love empowering People, aligning to Processes and delivering Projects.

Advertisements

General IT Notes on PHP Programming

PHP Case Sensitivity

PHP is considered partially case-sensitive. While language statements and functions are not case-sensitive, variable names are case-sensitive. For example, $variable and $VARIABLE would be treated as different entities.

Tags in PHP

PHP supports various tags for embedding PHP code within HTML or other documents:

  • Standard Tags: <?php ?> – These are the most commonly used tags for PHP code.
  • Short Tags: <? ?> and <?= $var ?> – Shorter alternatives to the standard tags. Note: Short tags are not always enabled in PHP configurations.
  • Script Tags: <script language="php"></script> – An older way of embedding PHP code, not commonly used now.
  • ASP Tags: <% %> – Similar to ASP style tags, supported for backward compatibility but not recommended for new code.

Variables in PHP

In PHP, variables are declared using the $ symbol. It is important to note the following about variables:

  • Curlies: Variables can be enclosed in curly braces like ${a} or {$a}. This is especially useful when accessing array elements within a string.
  • Quoting: Inside single quotes, variables are not directly interpolated. To include variables in strings, use double quotes instead.

Comments in PHP

Comments in PHP help in documenting code and are not executed by the PHP parser. PHP supports various types of comments:

// Single line comment using double slashes.

# Single line comment using hash.

/* Multi-line
   comment using slash-asterisk.

/**
* API Documentation Example.
*
* @param string $bar
*/

// Heredoc syntax for multi-line strings.

<<<EOT
... text
EOT;

// Nowdoc syntax for multi-line strings. Introduced in PHP 5.3.0.

<<<'EOT'
... text
EOT;

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x