| Advertisement |
Your text ad could be here for only $12/month!
Click here for more info!
|
| |
|
Php how-to for starters Taking web design to the next extreme By Red Squirrel
Ever wonder how people make those fancy sites where you can type in information and it actually "updates the page" right away? Ever wonder how forums do that? It's actually quite simple. PHP means Hyper Text Pre Processor. PHP is basically html, but with advanced preprocessing features. The HTTP protocol transfers hyper text, so it is called a Hyper Text Transfer Protocol. PHP is a "phase" that the document goes through before it is sent out to the client. It "pre processes" the data before sending it in. This is also known as a dynamic document. Any forum you go to is dynamic. The same document on the server (usually index.php) is being loaded, but it does not always send the same thing to the client even if it is not manually updated by the webmaster. This image will show you in general how php documents are processed:
Php does not only allow you to do cool stuff such as a forum, but it makes every webmaster's life much easier when running a website. While PHP is very good, it does have a few downsides, such as the fact that it is not something that "just works" like html. Html is simple because it is the exact document that is on the server, all the server does is send you the exact document when you request it, but php is a scripting language with html and it needs to be executed before sent. This requires that PHP is installed on the server. If it is not installed, the client simply gets the code, and not what the code is suppose to do since there's nothing to execute it. Another down side is that creating large/complex scripts can be difficult without a test server or unlimited bandwidth plan since you can't test it by just opening it in your browser but have to upload it every change to see if everything is going ok. As skills get better, you will be able to create complex scripts without uploading as often.
If you have two computers networked with a router, you can do a setup like mine. One of them can run as server, and also have a netbios share to the web server's directory, so you can open it on your main computer to edit and hit save, and then hit refresh on your browser which is opened to the page on the server. This makes it quick and easy to program, and makes it so you don't need to upload your files or anything.
On the next page, I'll show you how to get hooked up with a server capable of serving php pages.
Next Page
| 29016 Hits |
Pages: [1] [2] [3] [4] [5] |
40 Comments |
|
Latest comments (newest first) |
Posted by Guest on March 03th 2006 (11:06)
Very interesting and beautiful site. It is a lot of helpful information. Thanks!

|
Posted by Cesar on January 01th 2006 (08:13)
Hello. I am new at this, and I need to build a web page. I will use for sure PHP and MySQL. However, I am new at all this stuff, so I would really be thankfull if you could give me your oppinion on the following: 1) Is Apache the best solution to perform with PHP and MySQL? 2) I am not a programmer, so I have a lot to run... I have never worked with Linux, but for what I have read, it seams that using this applications with Linux is better than with Windows. What do you say on this? 3) I would like to have a forum (chat) and kind of a blog (comments to published notices). What would you advise me for each?? (At this point I realy don't know much even where to start, or what does it implies to administrate each one...)
thank you very much

|
Posted by viraj on October 10th 2005 (03:15)
hello i have recently installed PHP designer 2005. can u guide me for how to run php code in designer

|
Posted by halojoy on June 06th 2005 (21:36)
Yes, it is nice with scripts that does note produce notices. isset is a good way to avoid this, if you do not want to add a lot of code that sets 'empty' values for variables
Another way is to TURN OFF reporting of NOTICE you add this, at top (beginning) of your php pages:| CODE | <?php
// Report ALL, but not NOTICE error_reporting ( E_ALL & ~E_NOTICE );
// You will still get WARNINGS and other real ERRORS // Notice is not an error, just a note // To not have to add it in all your pages you can make it a line in 'config.php' , // if you have such a file, that is included by php pages ?> |
I use E_ALL = reporting with notices only when working with my code When I am finished and put my code on website, I Turn Notice OFF, using that line. I do not want to scare my visitors
Posted by Terry on June 06th 2005 (20:54)
Your article has been very useful. When I implemented your example it functioned as described with the exception that a number of notices were generated. All of the notices were complaining about undefined constants. After some digging around and experimentation I found that the notices could be eliminated by the use of isset and by quoting names in the $_GET and $_POST functions. For what it is worth the following is a rewrite of the example which, at least in my environment, eliminated all of the notices: NOTE: The leading underscore characters, "_", at the start of some lines represent spaces and/or tabs.
<?php ____if(isset($_GET["act"]) && $_GET["act"]=="go") ____{ ________echo("Your name is ".$_POST["name"]. ____________" And your age is ".$_POST["age"]. ____________"<br>Goodbye"); ____} ____else ____{ ?>
<form method="post" action="script.php?act=go"> ____Enter your name: <input type="text" name="name"><br> ____Enter your age: <input type="text" name="age"><br> ____<input type="submit" value="done!"> </form>
<?php ____Return; ____} ?>

| View all comments Post comment | |
|
|