Start Learning Very Simple PHP

1 - I can do better 2 - Jury's out 3 - Pretty darn good 4 - Splendiferous 5 - Awesometastic by 1 person | Log in to rate

Ranked #6,764 in Tech & Geek, #155,192 overall

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 customize....

Hello World 

This is the simplest script possible, meant for beginners

<?php ="Hello world" ?>

this can also be written

<?php echo "Hello world" ?>

Make Today's Date Appear on your Webpage 

<?php echo date(); ?>

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 

Create a file test.php with notepad or better
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

<?php $sum=1+2+7; ?>

The Sum is <?php echo $sum ?>

PHP Books on Amazon 

PHP and MySQL Web Development (4th Edition)

Amazon Price: $34.64 (as of 12/02/2009) Buy Now

PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide

Amazon Price: $29.69 (as of 12/02/2009) Buy Now

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems

Amazon Price: $19.77 (as of 12/02/2009) Buy Now

PHP Object-Oriented Solutions

Amazon Price: $24.41 (as of 12/02/2009) Buy Now

Making Decisions 

if-elseif-else this is the core of programming logic

<php
$dayofweek = date('D');
if ($dayofweek=='Mon')
{
echo "It's Monday";
}
else
{
echo "It's not Monday";
}
?>

Display your URL/domain Name 

<?php

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 

The normal way of outputting text is

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 eBay 

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

PHP Guestbook 

What would you like to see?

submit
  • Reply
    sbucciarel sbucciarel Aug 25, 2008 @ 3:17 pm
    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

Learn More About PHP 

Is there a better book out there? If so list it below.

created by giltotherescue

by thesuccess

I am a wanderer of the vast lonely plains of the Internet always looking for something extraordinary, and now by some strange Serendipity we meet!

com... (more)

Explore related pages

Create a Lens!