Difference between revisions of "PHP"

From Conservapedia
Jump to navigation Jump to search
(changed to "Proccessed Into")
(all variables begin with a dollar sign - makes string embedding easy)
Line 6: Line 6:
  
 
PHP is an ''interpreted language'' (like Perl) and not a ''compiled'' one (like [[Java]] or [[C]]).  
 
PHP is an ''interpreted language'' (like Perl) and not a ''compiled'' one (like [[Java]] or [[C]]).  
 +
 +
==String handling==
 +
 +
The [[string concatenation]] operator is the period (or full stop). This is a big difference from most other languages, which use a plus sign or ampersand.
 +
 +
Example:
 +
 +
<code>
 +
  $first = "car";
 +
  $second = "nation";
 +
  $product= $first . $second;
 +
 +
  // Equivalent to:
 +
  $product= "carnation"
 +
 +
PHP recognizes variable names within strings which are enclosed in double quotes.
 +
Since all variables begin with a dollar sign, it is easy to embed one string inside another. This is the preferred way to create HTML output.
 +
 +
For example:
 +
 +
    $first = "John";
 +
    $middle = "Quincy"
 +
    $last = "Adams";
 +
   
 +
    // Show full name, in bold format
 +
    $echo <nowiki>"<B>$first $middle $last</B>";</nowiki>
 +
 +
 +
This outputs <nowiki>"<B>John Quincy Adems</B>"</nowiki> to the HTML page.
  
 
==Databases==
 
==Databases==

Revision as of 16:54, July 11, 2007

PHP is a server-side scripting language for creating interactive web pages. The acronym PHP derives from Personal Home Page, but now it is defined as "PHP: Hypertext Pre-Processor" (it means "something to handle data before it becomes HTML" [1] ). Unlike HTML, JavaScript and others, PHP is a Server-Side scripting language. It most always is processed into HTML for use in a web page.

PHP is one of the most popular scripting languages in the Open Source world, which is often used together with Apache on Linux or on other paid platforms such as Microsoft IIS on Windows.

The PHP syntax is very similar to Perl and C. [1]

PHP is an interpreted language (like Perl) and not a compiled one (like Java or C).

String handling

The string concatenation operator is the period (or full stop). This is a big difference from most other languages, which use a plus sign or ampersand.

Example:

 $first = "car";
 $second = "nation";
 $product= $first . $second;

 // Equivalent to:
 $product= "carnation"

PHP recognizes variable names within strings which are enclosed in double quotes. Since all variables begin with a dollar sign, it is easy to embed one string inside another. This is the preferred way to create HTML output.

For example:

   $first = "John";
   $middle = "Quincy"
   $last = "Adams";
   
   // Show full name, in bold format
   $echo "<B>$first $middle $last</B>";


This outputs "<B>John Quincy Adems</B>" to the HTML page.

Databases

PHP is compatible with multiple databases, MySQL being the most popular.

Overall, PHP is compatible with:

  • MySQL
  • PostgreSQL
  • MS-SQL 2000
  • Oracle

and many others.

Books

  • How to Do Everything with PHP & MySQL, Vikram Vaswani (McGraw-Hill, 2005)

External links