PHP

From S23Wiki
Jump to: navigation, search

PHP is an ever-popular web scripting engine. It allows you to create dynamic web pages easily and quickly. It has a very rapid learning curve so once you get the basics down you'll progress very quickly and start writing some nifty scripts. In newbie terms: it's a thingy that runs in conjunction with a web server that easily allows you to create web pages that change -- such as guestbooks, list users' comments, discussion boards, top fifty lists, administration panels ... and so forth. Yeah ok, so how do I use it?

Firstly you must ensure you have access to a web server that is compiled or set up to work in conjunction with PHP. Most good web hosts these days will offer PHP support, and if they don't you can always bombard them with e-mails and whine until they do. PHP is getting very popular so the chances are you'll have access to it. If you don't you can always install it yourself on your own system, along with a web server. You can find instructions on how to do this, on a wide range of operating systems, in The PHP Manual.

So How Do I write It?

PHP is very simple to use, the first thing to note is that PHP is embedded into HTML. You don't have to have pure PHP code in a PHP document, you can switch between HTML and PHP

--- http://www.php.net/

What is PHP?

PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

Tutorial: http://www.php.net/tut.php

Manual: http://www.php.net/docs.php

PHP security: SecurePHP-Wiki


Example:


<?php

echo 'Hello Fnords';

?>

---

http://www.free2code.net/tutorials/php/Introduction_to_PHP

---

String Comparisons

strstr (case-sensitive)

stristr (case-insensitive)

Testing if a string is found or not

<?php
  $string = 'Hello World!';
  if(stristr($string, 'earth') === FALSE) {
   echo '"earth" not found in string';
  }
// outputs: "earth" not found in string
?> 

Regular Expressions

Regular Expressions PHP Tutorial

Use only IPv6 in URLs

<?php
var_dump(file_get_contents('http://[::1]/'));
?>