Learn PHP with these Really Simple Scripts
This Lens is designed to encourage non-techies to start learning PHP the Web's most popular Scripting Language. It does this by listing very simple scripts that are designed to give Newbies confidence.
Lots of the most popular website applications are written using PHP. So a website form, quiz or poll might use PHP. Wordpress the very popular blogging platform uses PHP. Normally you can download and install the above PHP applications, without any technical knowledge; however sooner or later even non-techies get the urge to customise....
PHP Tips Table of Contents
- Hello World
- Make Today's Date Appear on your Webpage
- How to Find out if you have PHP installed on your Website
- Simple Maths
- PHP Books on Amazon
- Making Decisions
- Display your URL/domain Name
- PHP Web Links
- Outputting blocks of text or HTML
- PHP on CafePress
- PHP on eBay
- PHP Guestbook
- New Amazon Voting (Plexo)
Hello World
This is the simplest script possible, meant for beginners
this can also be written
<?php echo "Hello world" ?>
Make Today's Date Appear on your Webpage
You can also format the date
<?php echo date("Y-m-d H:i:s"); ?>
How to Find out if you have PHP installed on your Website
Containing
<?php phpinfo(); ?>
FTP this up to your Website and execute with
http://www.mywebsite.com/test.php
If PHP is enabled on your website then 3 or 4 screens of details about your PHP installation will appear.
PHP is normally available on websites you have purchased, as apposed to most "free" websites
Simple Maths
Doesn't do anything useful
The Sum is <?php echo $sum ?>
PHP Books on Amazon
Making Decisions
if-elseif-else this is the core of programming logic
$dayofweek = date('D');
if ($dayofweek=='Mon')
{
echo "It's Monday";
}
else
{
echo "It's not Monday";
}
?>
Display your URL/domain Name
echo $_SERVER['HTTP_HOST'];
?>
PHP Web Links
- PHP Main Website
- The Main PHP Website for downloads and documentation
- PHP on Wikipedia
- Great Overview
- PHP Tutorial
- Free PHP tutorials, references, examples for web building.
Outputting blocks of text or HTML
echo 'Here is some text';
or
echo "I am $age years old";
However when you want to output a lot of text that may contain single or double quotes, the "heredoc" shown below is more elegant
echo <<<'EOD'
Example of string
spanning multiple lines
using nowdoc syntax.
EOD;
Learn more here php.net/types.string
PHP on CafePress
PHP Guestbook
What would you like to see?
sbucciarel wrote...
Great lense. The Firestorm Forum is great for promoting your lenses and blogs. There's a very active Squidoo community there. firestormforum.com Hope you check it out. I also have a lense about it at http://www.squidoo.com/firestorm

Fetching new data from eBay now... please stand by

