I.T. Discussion Community!
-Collapse +Expand
PHP
Search PHP Group:

Advanced
-Collapse +Expand PHP Store
PRESTWOODSTORE

Prestwood eMagazine

May Edition
Subscribe now! It's Free!
Enter your email:

   ► KBWebsite Scri...PHPBeginners Co...   Print This     
  From the January 2016 Issue of Prestwood eMag
 
PHP Beginners Corner:
A 10 Minute PHP Quick Start
 
Posted 13 years ago on 2/10/2006 and updated 7/15/2010
Take Away:

An Introduction to PHP. Installing PHP on Your Computer and Running your First Script.

 Tags: Install PHP

KB100302



Got 10 minutes? Want to get started with PHP?

This article is part of our series of 10 Minute Quick Starts. Each quick start is step by step, assumes you know very little about the subject, and takes about 10 minutes. You can use them to scratch the service of areas you want to learn and as a quick review when returning to something after a long absence.

Setup

If you don't have PHP installed, the first thing to do is to go to the PHP Website and download the PHP installer.

Install PHP. If you're on a Windows development box make sure you have IIS installed. If you do, the PHP installer will find it and automatically configure itself to be used with IIS.

And here, we, go...

1. Test PHP. Open up notepad (or any text editor) and enter the following code:

<?PHP 
$myvar = "Hello, World!";
echo $myvar;
?>

 

A complete example inside an HTML page might look like the following:

<html>
<head>
<title>PHP Test</title>
</head>
  
<body>
<?PHP
$myvar = "Hello, World!";  
echo $myvar; 
?> 
</body>
</html>
  

And save it as "index.php" in your default web folder (IIS's default folder is C:\Inetpub\wwwroot.

 

2. Open a browser and browse to the page you just created to see the results of your Hello World example.

To explain the above code: - All PHP code must be placed between these tags:

<?PHP          ?>

$myvar = "Hello, World!"; - $myvar is a variable and we are assigning the text string "Hello, World!" to it Echo $myvar; - we are printing the contents of the $myvar variable to the browser screen. Open Internet Explorer and enter /index.php (or the location of your web folder). You should see Hello, World! printed to the screen. And that's it, installing PHP and running PHP scripts are THAT easy.

 

3. You can embed PHP code between the <?PHP and ?> tags anywhere in your HTML page. The next, and last, example of this short tutoral shows that you can have PHP code on multiple lines and introduces the phpinfo function and comments.

<?php 
//This is a single line comment!
echo 'The following displays system information.';
echo phpinfo(); 
/*
As you can see, PHP is very easy to code in.
This is an example of a multi-line comment.
*/
?> 

Good luck!

More Info

FAQ:  Delphi PHP V
Download:  Download PHP (Install it)

Comments

0 Comments.
Share a thought or comment...
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1261A1
Enter key:
KB Post Contributed By Adam Lum:

Adam Lum is a part time developer for Prestwood Software and participates in this online community when time allows. His day-to-day work is C# coding but his current intrests (right now) are Ruby on Rails and iOS programming with Objective-C.  He has also coded several projects in Java, C++, ASP Classic, and PHP.  His personal website can be found at adamlum.com.

Visit Profile

 KB Article #100302 Counter
12396
Since 4/2/2008
Follow PrestwoodBoards on: 


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech