Archive for July, 2007

58Part IPHP: The BasicsThey are called from a (Web hosting directory)

Friday, July 20th, 2007

58Part IPHP: The BasicsThey are called from a PHP page this way:

This is some body text for this particular page.

Obviously, this single move greatly enhances the maintainability and scalability of an entiresite. Now, if you want a different look and feel or if you need to update the copyright notice, you can alter one file instead of identical lines in dozens of HTML pages. When including files, remember to set the include_pathdirective correctly in yourphp.inifile. Remember that you can include files from above or entirely outside your Webtree by proper use of this directive. See Chapter 30 for more information. As you can see from the preceding example, PHP s includefunctions simply pass along thecontents of the included file as text. Many people think that because an includefunctionoccurs inside PHP mode, the included file will also be in PHP mode. This is not true! Actually, the server escapes back into HTML mode at the beginning of each included file and silentlyreturns to PHP mode at the end, just in time to catch the semicolon. As always, you need to say when you intend something to be PHP by using PHP opening andclosing tags. Any part of an included file that needs to be executed as PHP should beenclosed in valid PHP tags. If the entire file is PHP (very common in files of functions), theentire file must be enclosed within PHP tags. Take the following file, database.inc: $db = mysql_connect( localhost , db_user , db_password ); mysql_select_db( my_database ); We can t emphasize this enough: If you re having problems including PHP files, particularly ifyou re seeing output you don t expect or not seeing output you do expect, be ABSOLUTELYPOSITIVEthat you ve put PHP tags at the beginning and end of the included file. If you were to foolishly include this file from a PHP script, your database variables would bevisible to the world in plain text because you neglected to use PHP tags, the parser assumesthis block of code is HTML. A correct version of the database.incfile would look like this: For all PHP files included from other files, you must ensure that there are no empty new linesat the end of the file. Remember, anything outside a PHP block is considered HTML, even ablank line. Blank lines, or even blank spaces outside a closing PHP tag, will be interpreted asoutput. If you include the file in a situation where you cannot have output say before usingHTTP headers your script will fail with a big error message about the output stream havingalready been started in your included file. See Chapter 11 for an example. CautionCautionTip06
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

57Chapter 4Adding PHP to HTMLNotice that things that (Web hosting ecommerce)

Thursday, July 19th, 2007

57Chapter 4Adding PHP to HTMLNotice that things that happened in the first PHP mode instance in this case, a variablebeing assigned are still valid in the second. In Chapter 5, you ll learn more about what happens to variables when you skip in and out of PHP mode. In Chapter 33, you ll also learnabout different styles of using PHP mode. Including filesAnother way you can add PHP to your HTML is by putting it in a separate file and calling it byusing PHP s includefunctions. There are four includefunctions: .include( /filepath/filename ) .require( /filepath/filename ) .include_once( /filepath/filename ) .require_once( /filepath/filename ) In previous versions of PHP, there were significant differences in functionality and speedbetween the includefunctions and the requirefunctions. This is no longer true; the two sets of functions differ only in the kind of error they throw on failure. Include()andinclude_once()will merely generate a warning on failure, while require()andrequire_once()will cause a fatal error and termination of the script. As suggested by the names of the functions, include_once()and require_once()differfrom simple include()and require()in that they will allow a file to be included only onceper PHP script. This is extremely helpful when you are including files that contain PHP func- tions, because redeclaring functions results in an automatic fatal error. In larger PHP systems, it s quite common to include files which include other files which include other files it canbe difficult to remember whether you ve included a particular function before, but withinclude_once()or require_once()you don t have to. How do you decide on a preferred includefunction? In essence, you must decide whetheryou want to force yourself to write good code on pain of fatal error or whether you want it torun regardless of certain common errors on your part. The strictest alternative is require(), which will bring everything grinding to a halt if your code isn t perfect; the least strict isinclude_once(), which will good-naturedly hide the consequences of some of your bad coding habits. The most common use of PHP s includecapability is to add common headers and footers toall the Web pages on a site. For example, a simple header file (cleverly named header.inc) might look like this: A site title Similarly, a footer file called footer.incmight consist of:

Copyright 1995 - 2002


In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

56Part IPHP: The BasicsFigure 4-1:Your first PHP scriptRefer (Web hosting india)

Thursday, July 19th, 2007

56Part IPHP: The BasicsFigure 4-1:Your first PHP scriptRefer to Chapter 3 for installation instructions, and forward to Chapter 30 for configurationoptions. Chapter 11 diagnoses some common early problems and gives debugging hints. Jumping in and out of PHP modeAt any given moment in a PHP script, you are either in PHP mode or you re out of it in HTML. There s no middle ground. Anything within the PHP tags is PHP; everything outside is plainHTML, as far as the server is concerned. You can escape into PHP mode with giddy abandon, as often and as briefly or lengthily asnecessary. For example:

First name:

Last name:

Rank: >


Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

55Chapter 4Adding PHP to HTMLIf you ve made the (Web hosting billing)

Thursday, July 19th, 2007

55Chapter 4Adding PHP to HTMLIf you ve made the virtuous decision to eschew the short-open tag, remember to disable it inyour php.inifile. You want to see an error message when you inadvertently forget to com- plete your tag correctly. ASP-style tagsASP-style tags mimic the tags used by Microsoft Active Server Pages to delineate code blocks. ASP-style tags look like this: <% %> People who use FrontPage as a development tool often choose this style. To use ASP-styletags, you will need to set the configuration option in your php.inifile. Obviously, if you useASP-style tags and the .aspsuffix (which you may wish to do if you re converting from anASP site or spoofing ASP for some reason), you will need to disable ASP on your IIS server. Otherwise, two different scripting engines will be trying to parse the same blocks of codewith unpredictable results. HTML script tagsHTML script tags look like this: Although this is effective and also gets around the FrontPage problems, it can be cumber- some in certain situations, such as quick pop-in variable replacement. In particular, be carefulif you use lots of JavaScript on your site since the close-script tags are fatally ambiguous. TheHTML script tag is best used for fairly sizable blocks of PHP code. Hello WorldNow we re ready to write our first PHP program. Open a new file in your preferred editor. Type: My first PHP program
n ); phpinfo(); ?> In most browsers, nothing but the PHP section is strictly necessary. However, it s a good ideato get in the habit of always using a well-formed HTML structure in which to embed your PHP. If you don t see something pretty close to the output shown in Figure 4-1, you have a problem most likely some kind of installation or configuration glitch. Review Chapter 3, and make doublysure your installation succeeded. Tip06
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

54Part IPHP: The BasicsEverything within these tags is (Web design course)

Thursday, July 19th, 2007

54Part IPHP: The BasicsEverything within these tags is understood by the PHP parser to be PHP code. Everythingoutside of these tags does not concern the server and will simply be passed along and left forthe client to sort out whether it s HTML or JavaScript or something else. There are four styles of PHP tags and different rationales for using them. Part of the decision, however, is simply individual preference: what the individual programmer is comfortable withor what a team has decided upon for reasons of their own. Canonical PHP tagsThe most universally effective PHP tag style is: If you use this style, you can be positive that your tags will always be correctly interpreted. Unless you have a very, very strong reason to prefer one of the other styles, use this one. Some or all of the other styles of PHP tag may be phased out in the future only this one iscertain to be safe. Short-open (SGML-style) tagsShort or short-open tags look like this: Short tags are, as one might expect, the shortest option. Those who escape into and out ofHTML frequently in each script will be attracted by the prospect of fewer keystrokes; how- ever, the price of shorter tags is pretty high. You must do one of two things to enable PHPtorecognize the tags: .Choose the –enable-short-tagsconfiguration option when you re building PHP. .Set the short_open_tagsetting in your php.inifile to on. This option must be disabled to parse XML with PHP because the same syntax is used for XML tags. There used to be a third way to enable short-open tags: the short_open()function. Thisceased to be supported as of PHP4. There are several reasons to resist the temptation of the short-open tag. The most compellingreason now is that this syntax is not compatible with XML and since XHTML is a type ofXML, this implies that none of your code will be able to validate as XHTML. PHP code writtenwith short-open tags is less portable because you can t be sure another machine will haveenabled them. Short-open tags are also harder to pick out visually on the page, and many syn- tax-highlighting schemes don t support them. Beginners should be encouraged to start offwith the canonical style tag if at all possible. The short-open tag was one of many hacky ease-of-use ideas that ended up biting the PHPcommunity years later. The PHP development team must now struggle to balance desires fora more standard and consistent syntax with a large installed userbase, which has written ahuge pile of code in the old style. As XML becomes more and more central to Web develop- ment, and as we move toward XHTML as the standard for Web page development, the short- open tag faces a shaky future. Do yourself a favor and start moving toward the canonical PHPtags now. Caution06
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Adding PHP to HTMLAfter all those preliminary exertions, (Adelphia web hosting)

Wednesday, July 18th, 2007

Adding PHP to HTMLAfter all those preliminary exertions, we finally get to the point ofwriting our first PHP scripts. Here you ll learn about PHP mode, PHP tags, and how to include other files in your PHP scripts. You llalso write your very first PHP program. Your HTML Is Already PHP-Compliant! PHP is already perfectly at home with HTML in fact, it is generallyembedded within HTML. As you ll see in later chapters, PHP ridespiggyback on some of the cleverer parts of the HTML standard, suchas forms and cookies, to do all kinds of useful things. Anything compatible with HTML on the client side is also compatiblewith PHP. PHP could not care less about chunks of JavaScript, calls tomusic and animation, applets, or anything else on the client side. PHPwill simply ignore those parts, and the Web server will happily passthem on to the client. It should thus be clear that you can use any method of developingWeb pages and simply add PHP to that method. If you re comfortablehaving teams work on each page using huge multimedia graphicssuites, you can keep on doing that. The general point is that youdon t need to change tools or workflow order just do what you vebeen doing and add the server-side functionality at the end. Escaping from HTMLBy now you re probably wondering: How does the PHP parser recog- nize PHP code inside your HTML document? The answer is that youtell the program when to spring into action by using special PHP tagsat the beginning and end of each PHP section. This process is calledescaping from HTMLor escaping into PHP. Not to confuse you, but escapein this sense should not be con- fused with another common use of the term escapein PHP: putting a backslash in front of certain special characters (such astab and newline) within double-quoted strings. Escaping strings isexplained in Chapter 8. Caution44CHAPTER …In This ChapterEscaping into PHPmodeChoosing PHP tag stylesWriting a Hello Worldprogram in PHPIncluding files …
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Yahoo web hosting - 51Chapter 3Getting Started with PHPIf you decide to

Wednesday, July 18th, 2007

51Chapter 3Getting Started with PHPIf you decide to self-host or maintain a development environment, detailed installationinstructions are provided in previous sections of this chapter for the most common plat- forms. PHP5 has SAPI support for many other Web servers, but installation directions for allof them would have made this chapter unreasonably lengthy. Finally, before you can start developing, you will want to give some thought to which develop- ment tools are best adapted to PHP. Although the long-awaited PHP-specific IDE is now avail- able from Zend, most PHP developers still simply use their favorite text editors. It is possibleto add PHP to the product of a WYSIWYG editor, but it can be messy. …
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

50Part IPHP: The BasicsIn addition to these popular (Web site translator)

Wednesday, July 18th, 2007

50Part IPHP: The BasicsIn addition to these popular choices, Keith Edmunds maintains a longer list of PHP-suitable texteditors, many available at no or low cost from http://phpeditors.linuxbackup.co.uk/. Take a deep breath after all that installing and configuring, you should now be ready towrite your first PHP script, which you ll do in Chapter 4. Table 3-2: Popular PHP Editors by PlatformPlatformProductDescriptionMacintoshBBEdit (www.barebones.com) Many Mac developers can t imagine life without it. Integrated in the Macversion of WYSIWYG packageMacromedia Dreamweaver. A no-costversion, BBEdit Lite, is also available. Unixemacs (www.gnu.org/software/emacs)Not for the faint of heart. Good PHP Windowsxemacs (www.xemacs.org)syntax highlighting is finally available at Macintoshhttp://sourceforge.net/ projects/php-mode/. Available on every OS imaginable. Unixvim (www.vim.org)An improved variant of vi, now Windowsstandard on many Unices. This is the Macintoshkinder, gentler Unix hacker s editor, with a notably friendly community. Itwas the first major editor to have PHPsyntax highlighting. Available on almostevery OS. LinuxZend Studio (www.zend.com)The first development tool specifically Windowsdesigned for PHP. debugger, code Macintoshcompletion, and HTML output viewer. WindowsHomeSite (www.macromedia.com/Perennially popular Windows software/homesite/) commercial text editor. Integrated withthe Windows version of WYSIWYGpackage Macromedia Dreamweaver. WindowsNotepad (included with all Believe it or not, many people build Windows systems)fine sites using this crudest of tools. SummaryBefore you can use PHP, you need to decide whether you will self-host, outsource, or adopt acompromise solution, such as colocation. Some important factors in the decision are cost, size and traffic of site, unusual hardware or software needs, type of content, and desire forcontrol. The best candidates for external Web hosting are small sites without unusual require- ments or sites large enough to require at least one entire server to themselves.
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

49Chapter 3Getting Started with PHPFigure 3-1:Screenshot (Web file server) of Zend

Wednesday, July 18th, 2007

49Chapter 3Getting Started with PHPFigure 3-1:Screenshot of Zend Studio IDERemember that your development client doesn t necessarily have to be on the same operat- ing system as the server this is the beauty of truly cross-platform development. This is particularly valuable if you re using a Unix server, where (to paraphrase The Blues Brothers) We have both kinds of editor: emacsand vi. It must be admitted that Macintosh andWindows have a wider selection of slicker, more user-friendly text editors. Unix, on the otherhand, makes it easy to support multiple client OSes. Many development shops take advan- tage of this best of all worlds situation. emacs, vi, and Zend Studio are editors that come inall the major client platforms so if your team standardizes on one of those, you will be ableto accommodate all client OS preferences. Table 3-2 shows a matrix of the most popular programmer s editors, with information on thedifferent operating systems they run on. If you re going to have developers using multiple OSes, remember that linebreaks and someother characters are incompatible between Windows and Unix. Unix-style linebreaks showup as black boxes in Notepad, while Windows linebreaks look like ^Min Unix text editors. Your PHP scripts will probably still work fine (although in some version control situations itcan break code), but you ll drive each other crazy if you have to edit each other s code. Thebest way to deal with the incompatible linebreaks issue, and a heck of a good idea for a lotof other reasons, is to use a version control system such as CVS and set it to strip linebreaks. Caution05
You want to have a cheap webhost for your apache application, then check apache web hosting services.

Web hosting domain names - 48Part IPHP: The BasicsThose coming to PHP from

Tuesday, July 17th, 2007

48Part IPHP: The BasicsThose coming to PHP from a strictly client-side perspective probably have the hardest adjust- ment to make. There s no such thing as a plush development environment with wizards anddrag-and-drop icons and built-in graphics manipulation. If that sort of thing is important toyou, you can use a WYSIWYG editor to format the page and then add PHP functionality laterusing a text editor. The downside of this strategy is, of course, that machine-written code isoften not very human-readable but one must suffer to be pretty. The last year and a half, however, has seen substantial change in the market. Plenty of editorsfor both Windows and Linux now offer at least syntax highlighting for PHP. Several of thesecan map drive locations to server names so you can debug in place. Even the WYSIWIGDreamweaver now claims some degree of PHP support. It still can t write the code for you, and you probably wouldn t want that if it could but it won t change your code either. Be particularly careful with using Microsoft FrontPage as a PHP editor, as it seems to causeproblems for many users. At a minimum, you will need to enable (by choosing the option inyour php.inifile) and use ASP-style tags; or use JavaScript-style