Tag: Php Help

A Beginner’s Guide To Php
By Ehsen Siraj

PHP is officially known as PHP: HyperText Preprocessor. It is a server-side scripting language just like Active Server Pages (Asp), Java Server Pages (Jsp) and Cold Fusion (CF). It is usually written in an HTML context. Unlike an ordinary HTMLpage, Server doesn’t send php script directly to a client; instead, it is parsed by the PHP binary or module. HTML in the script is ignored, but PHPcode is interpreted and executed. PHP code in a script can query databases, create images, read and write files, talk to remote servers- the possibilities are endless. Finally the php code result and HTML is combined and output is send to the client.

PHP Installation on your computer   In order to run php on your computer you must have following components installed on it.

1. Web Server (IIS or Apache)

2. PHP

3. Mysql (optional)

Most websites advise you to install all components manually but its just wastage of time. Visit [http://www.wampserver.com/ ]http://www.wampserver.com and install latest version of WAMP it will automatically install php, apache and mysql on your computer with a single click. Its an open source software and very easy to use.

How to run php scripts

During installation WAMP creates a “www” directory in the installation folder. Save all your php scripts in it and then call it from your browser like this

http://localhost/yourscriptname.php” where “yourscriptname” is the name of your php file.

First Script

Open your favorite text editor. Like HTML documents, PHP files are made up of plain text. You can create them with anytext editor, such as Notepad. However I advise you to use a specialized php editor. Macromedia Dreamweaver is the best php editor but its not free. You can find lots of good php editors at [http://www.sourceforge.net/ ]http://www.sourceforge.net

or simply Google it with keywords “free php editors”

Here is your first php script

 

1:

 

Save this script in www directory. Then call it from your browser like this

localhost/first.php

You will get following result;

Hello World

Remember : Always write your php code between opening and closing tags. Consider the following example.

 

Adding Comments to PHP Code

A comment is text in a script that is ignored by the interpreter. Comments make your life lot more easier because Code that seems clear at the time of writing, can be extremely frustrating when you come to amend it six or tweleve months later. Adding comments saves time besides it makes it easier for other programmers to work with your code.

You can make comments in many ways

Single line comments begin with two forward slashes (/ /) or a single hash sign (#).

All text from either of these marks until either the end of the line or the PHP close tag is ignored.

// this is a comment  # this is another comment

Multi line comments begin with a forward slash followed by an asterisk (/*) and end with an asterisk followed by a forward slash (*/).

/*

Add your text here.

Interpreter will not parse it

/*

Tags: , , , ,
php
Interested asked:


I am looking to find a PHP programmer to help program a website. I advertised in Craig’s list and other places and have a large number of resumes. I am not a computer programmer, and have very little knowledge regarding programming.

What sorts of questions should I ask to help me determine if the people we are interviewing are indeed good PHP programmers?

Thanks!

Tags: , ,
php and mysql
bob1704 asked:


I want to start using PHP and mySQL to help me with my work. Does anyone know if and how I can set up somewhere locally on my computer or something where i can test my pages and database as if it were live on a web server?

Tags: , ,
Back to top