understanding php

PHP is a scripting language that helps you create dynamic web sites. You can think of PHP and any "server-side" scripting option (ASP, JSP, etc.) as a go-between. It transfers information (such as a search query) from the user to the backend database or application; it then takes the results from the application and turns them into a web page.

For instance, some sites serve personalized information to returning customers ("Welcome back, June! The weather in New York is still awful!") Server-side scripts, like PHP, make this possible. They grab information about the user who requested the page, and pass it to the backend application, which runs on the server. The application decides what to do, based on what the script told it (Print the text: "Welcome back June!"), and the script translates that into a web page. All this usually happens in a matter of milliseconds.

Like all "server-side" scripting languages, PHP uses the power of your site's server to create these dynamic elements. It has many applications.

php is used to

  • Gather user information from forms.

  • Detect the user's browser and platform, and serve dynamic pages or elements.

  • Serve dynamic pages based on user input.

  • Serve randomized images or ads.

  • Track users through the site.

  • Reuse a single page template throughout the site.

PHP will work on any site whose server has the (free) PHP software installed.

Learn PHP

Webmonkey PHP tutorials

http://www.webmonkey.com/programming/php/


what you need to know about php

what it is

PHP is a scripting language that helps you create dynamic web sites. The commands are integrated into normal HTML files, but it uses the server's power to perform the tasks.

how it's used

PHP is most often used to link a database with a web site, drawing dynamic elements into otherwise static pages. It's also used for collecting user information from forms, generating dynamic page content based on user input or other factors, detecting the user's browser and platform, and tracking users through the site.

why it's loved

  • PHP is free!

  • It's intuitive, accessible, and relatively easy to learn even for non-programmers.

  • PHP is open-source, so it's developed by a software community (not a company) and the source code is freely available.

  • It's compatible with nearly every server.

  • It's compatible with a wide range of databases, including Sybase, Oracle, Informix, and the free, open-source MySQL.

why it's hated

Well, hate is a strong word. But PHP doesn't serve everyone's needs.

  • Integration with other systems isn't always as efficient as with commercial scripting options.

  • Other scripting options offer easier solutions for common procedures.

  • Other scripting options offer professional technical support (though you can get tech support for PHP through Zend: www.zend.com).


php vs. other server-side scripts

Of all the server-side scripting options (see the accompanying sidebar), PHP is the most talked-about. Not because it's the most powerful or because it's the best choice in every situation (it isn't), but because it puts the power of dynamic publishing in the hands of people who couldn't otherwise afford it.

PHP, you see, is an open-source technology. The needed software is available for free, so any site regardless of size, scale, or income can use it. All you have to do is install the free PHP software on your server (it works on nearly every operating system).

If you combine PHP scripts with a free, open-source MySQL database and free, open-source Apache server software, you can create a very affordable infrastructure for a very sophisticated site.

That said, PHP isn't the right choice for every site. Large-scale sites often choose one of the other options (ASP, JSP, ColdFusion, etc.). These scripting options will cost you more, but the benefits may be significant: They integrate more elegantly with other systems; they let you re-use code from other applications; and they offer easier solutions for complex, but common procedures, like integration with commerce engines. Plus, they offer professional technical support.

learning to use php

PHP commands can be incorporated directly into the HTML file that creates the web page (though the file should be renamed with the .php extension instead of .html.) The scripts appear in the file wherever they'll appear on the page and are always sandwiched between <?PHP and ?>.

If you have a simple PHP script like this:

 
 <?php print ("Behold the power of PHP!"); ?> 
 

The server creates an HTML page with this code:

 <p>Behold the power of PHP! 

Which appears on the web page as:

graphics/169fig01.gif

other server-side scripting options

PHP is popular, sure, but it isn't the only game in town. There are a lot of good options for server-side scripts; your choice depends on your taste, your technical requirements, and, of course, your budget.

ASP, or Active Server Pages (a Microsoft product), are dynamic pages, created on-the-fly by the server. Many application-based sites search engines, commerce sites deliver results in ASP. To create ASP (.asp) pages, you combine HTML with scripts (usually written in VBScript). To serve ASP pages, you need a Windows server or a Unix server enabled for ASP. One great advantage of ASP is that it allows developers to reuse software components, written in Visual Basic or Visual C++. This makes integration easier.

CGI scripts are the oldest scripting option on the web, and they're commonly used to provide the functionality behind forms. CGI scripts are usually written in the programming language Perl, and they'll run on any web server. Their biggest drawback is inefficiency: They require a lot of processing power from the server.

ColdFusion, a Macromedia product, was designed to help businesses link their databases with the web browser. To create ColdFusion (.cfm) pages, you combine HTML tags with ColdFusion scripts. Unlike other scripting solutions, which rely on existing languages like Visual Basic, ColdFusion uses its own scripting language, CFML (ColdFusion Markup Language) developed specifically for this purpose. You can serve ColdFusion pages from any server with the software installed.

JSP, or Java Server Pages (a Sun Microsystems product), are dynamic pages, created on-the-fly by the server. Many commerce sites deliver pages in JSP. To create JSP (.jsp) pages, you combine XML tags with small programs (called servlets) written in the programming language Java. JSP is very powerful, very fast, and viewed by many as the best choice for large-scale systems.




The Unusually Useful Web Book
The Unusually Useful Web Book
ISBN: 0735712069
EAN: 2147483647
Year: 2006
Pages: 195
Authors: June Cohen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net