Skip to navigation | Skip to content

Share your knowledge. Make a difference.

Learning PHP: A guide for marketers who dream of being programmers

1 - I can do better 2 - Jury's out 3 - Pretty darn good 4 - Splendiferous 5 - Awesometastic (by 1 person)   Your rating: 1 - I can do better 2 - Jury's out 3 - Pretty darn good 4 - Splendiferous 5 - Awesometastic

Ranked #5435 in Tech & Geek, #119015 overall

Rated G. (Control what you see)

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

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) (Developer's Library)

Amazon Price: $31.49 (as of 01/08/2009) Buy Now

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

Amazon Price: $26.39 (as of 01/08/2009) Buy Now

Head First PHP & MySQL

Amazon Price: $29.69 (as of 01/08/2009) Buy Now

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

Amazon Price: $19.77 (as of 01/08/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?

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

ReplyPosted August 25, 2008

X
thesuccess

About 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!

learn more about me at squidoo.com/thesuccess

thesuccess's Pages

See all of thesuccess's pages

X

Happy holidays!

The red bow is special. Whenever you see a red bow on a Squidoo page, it means the page is raising money for charity.

Buy something from the page, and we'll automatically make a donation to charity, thanks to you.