Archive for April, 2007

Affordable web design - 522Part IIIAdvanced Features and Techniquesdoes not contain the

Saturday, April 28th, 2007

522Part IIIAdvanced Features and Techniquesdoes not contain the PEAR PHP directory you just specified: If the specified directory is also not in the include_path usedby your scripts, you will have problems getting any PEARpackages working. Would you like to alter php.ini ? [Y/n] : YThat modifies the php.inifile, so the PEAR packages are accessible by the PHP engine. php.ini include_path updated. Current include path : .;c:php4pearConfigured directory : C:PHPpearCurrently used php.ini (guess) : c:winntphp.iniPress Enter to continue: The pear command is now at your service at C:PHPpear.batBrilliant the installation worked. It warns us, though, that the Windows PATHisn t really setfor maximum convenience: ** The pear command is not in your PATH, so you need to** use C:PHPpear.bat until you have added** C:PHP to your PATH environment variable. Run it without parameters to see the available actions, try pear list to see what packages are installed, or pear help for help. For more information about PEAR, see: http://pear.php.net/faq.phphttp://cvs.php.net/co.php/pearweb/doc/pear_package_manager.txt?p=1http://pear.php.net/manual/ Thanks for using go-pear! We re set at this point, but the installation program calls attention to a Windows Registryhack we can use for greater convenience if we want: * WINDOWS ENVIRONMENT VARIABLES * For convenience, a REG file is available underC:PHPPEAR_ENV.reg . This file creates ENV variables for the current user. Double-click this file to add it to the current user registry. Press any key to continue . . . The PEAR Package Manager is installed and available for use at this point.
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision ecommerce web hosting services

521Chapter 28PEARThe directory. Type all to change all (Ecommerce web host)

Saturday, April 28th, 2007

521Chapter 28PEARThe directory. Type all to change all of them or simply press Enter to accept these locations. 1. Installation prefix : C:PHP2. Binaries directory : $prefix3. PHP code directory ($php_dir) : $prefixpear4. Documentation base directory : $php_dirdocs5. Data base directory : $php_dirdata6. Tests base directory : $php_dirtests7. php.exe path : C:PHPcliphp.exe1-7, all or Enter to continue: We hit Enterto accept the default locations. It then lets us know that some PEAR packagesare already present on the system: The following PEAR packages are bundled with PHP: DB, Net_Socket, Net_SMTP, Mail, XML_Parser, phpUnit. Would you like to install these as well? [Y/n] : YOf course we would: Loading zlib: okUsing local package: PEAR………….okUsing local package: Archive_Tar……okUsing local package: Console_Getopt….okUsing local package: XML_RPC……….okBootstrapping: PEAR……………….(local) okBootstrapping: Archive_Tar…………(local) okBootstrapping: Console_Getopt………(local) okUsing local package: DB……………okUsing local package: Net_Socket…….okUsing local package: Net_SMTP………okUsing local package: Mail………….okUsing local package: XML_Parser…….okDownloading package: phpUnit……….okExtracting installer………………okinstall ok: PEAR 1.3b1install ok: Archive_Tar 1.1install ok: Console_Getopt 1.0install ok: XML_RPC 1.0.4install ok: DB 1.5.0RC2install ok: Net_Socket 1.0.1install ok: Net_SMTP 1.2.3install ok: Mail 1.1.2install ok: XML_Parser 1.0.1install ok: PHPUnit 1.0.0-alpha2**************************************************************** WARNING! The include_path defined in the currently used php.ini32
Note: In case you are looking for affordable and reliable webhost to host and run your business application check Vision ftp web hosting services

520Part IIIAdvanced Features and TechniquesRemember that if you (Remote web server)

Friday, April 27th, 2007

520Part IIIAdvanced Features and TechniquesRemember that if you just want to use PEAR s DB, Net_Socket, Net_SMTP, Mail, XML_Parser, or phpUnitmodules, you do not need to install the PEAR Package Manageror any packages! These packages, which are collectively referred to as the PEAR FoundationClasses, are bundled with PHP. Installing PEAR Package Manager on LinuxOn a Linux machine with PHP4.3 or a later version installed, there s no work to be done. ThePEAR Package Manager is by default already in place with your PHP distribution, and avail- able for use. If you re running an older version of PHP under Linux, you ll need to install the PEAR PackageManager by means of a two-part command. The command looks like this: $ lynx -source http://go-pear.org/ | phpThat command opens up the specified URL (which you can examine yourself through an ordi- nary Web browser) with Lynx, a text-only HTTP client (certain Linux distributions have simi- larly functional programs with different names, such as linksunder Red Hat Linux). The URLcontains text that defines a PHP program. The command line pipes that text to the PHPengine, thus allowing it to be interpreted. Installing PEAR Package Manager on WindowsOn a Microsoft Windows machine with PHP4.3 or newer installed, there is a file called go-pear.batin the PHP home directory (typically C:php). Before you can use the PEARPackage Manager, you must run go-pear.batand let it make some configuration changes to your system. Here s what it looks like when go-pear.batruns: C:PHP>go-pear.batWelcome to go-pear! Go-pear will install the pear command and all the files neededby it. This command is your tool for PEAR installation andmaintenance. Go-pear also lets you download and install the PEAR packagesbundled with PHP: DB, Net_Socket, Net_SMTP, Mail, XML_Parser, phpUnit. If you wish to abort, press Control-C now, or press Enter tocontinue: Following the directions in the code, we press Enterto continue and get the following: HTTP proxy (http://user:password@proxy.myhost.com:port), orEnter for none:: As we have no proxy, we hit Enteragain and get the following: Below is a suggested file layout for your new PEAR installation. To change individual locations, type the number in front ofTip32
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision best web hosting services

519Chapter 28PEAR .Auth User authentication .Benchmark Performance calibration (Apache web server tutorial) .DB Database connectivity

Friday, April 27th, 2007

519Chapter 28PEAR .Auth User authentication .Benchmark Performance calibration .DB Database connectivity .Calendar Calendar objects and functions .Archive_Tar Interaction with tar files .Archive_Zip Interaction with Zip files .HTTP Manipulation of the HTTP protocol .Image_Barcode Barcode generation .I18N Internationalization tools .Log Logging .Mail Interaction with POP, IMAP, and SMTP .Oggvorbis Interpretation of the Ogg Vorbis open-source audio file format .Tree Tree structures for organizing objects .SOAP Implementation of the SOAP protocolAside from enabling PHP server administrators to incrementally adjust the capabilities oftheir systems, the PEAR package system is a way of dividing the labor involved in expandingthe capabilities of PHP. Each of the many packages in the system there are more than 250as of this writing has a separate development team behind it, complete with a project leadand several other contributors. Individual packages have version numbers and (usually) theirown supporting documentation. Packages may depend on other packages (meaning that thedepended-upon package must be installed); managing these dependencies is one function ofthe PEAR package-management tool. How the PEAR database worksThe PEAR database serves two purposes: it is by design accessible to human readers as wellas to the PEAR package-management client. You can use an ordinary Web browser to navigatearound the HTML documents at the PEAR site (http://pear.php.net), or you can use thepackage-management client to interface with it via a Web service interface. Either way, the PEAR repository is organized as a tree, with related packages grouped intohierarchies (though hierarchical relationships do not necessarily indicate dependency rela- tionships among packages). The PEAR community manages what goes into the tree, deter- mining when development on a particular package has progressed far enough to warrant anew release into the publicly available repository. The Package ManagerIf, like most people, you re planning to use the PEAR repository as a resource rather than asan entity to which to contribute, your main interaction with it will be through the PEARPackage Manager. The package manager is a command-line program that interacts with theonline repository and allows you to download, install, and uninstall PEAR packages accordingto your requirements. This remainder of this section shows you how to get and use the PEARPackage Manager.
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision servlet hosting services

518Part IIIAdvanced Features and TechniquesThe PEAR project began (Web hosting provider)

Friday, April 27th, 2007

518Part IIIAdvanced Features and TechniquesThe PEAR project began in 1999, shortly after PHP itself came into being. It s a community- driven initiative dedicated to generating open-source code that improves PHP. PEAR packagesare built on top of the standard PHP functions, and are often written in an Object-Orientedstyle (for example, classes). You include these modules from your own PHP script with aninclude()or require()statement, as you would any other PHP function library or class. For the most part, PEAR is to PHP as the Comprehensive Perl Archive Network (CPAN) is toPerl. It has many parts, but the best-known and most frequently used is a library of open- source PHP code modules that may be accessed in an automated way. The PEAR modulemanagement system makes it easy for you to keep a server s PHP installation up-to-date andoutfitted with the elements it needs to do its job (for example, with the PEAR DB classes forstandardized database access and the PEAR LDAP classes for accessing a corporate direc- tory). You can run the package manager as an automated routine that checks for updated versions of your installed packages every week, if you like. Other parts of the PEAR project include: .A set of coding standards that specifically applies to PHP modules distributed by PEAR. .The PHP Foundation Classes (PFC), which are a few especially worthy PEAR classesdistributed with the main PHP package. .Various code archives and mailing lists for the people doing PEAR module develop- ment work. The PHP Extension Community Library (PECL) is a collection of PHP extensions (written in Cas all PHP extensions are) which are relatively rarely used and therefore do not need to bepart of the core PHP distribution (which was threatening to become too large and unwieldy). PECL used to be part of PEAR, but has been split off for separate management. PECL andPEAR share the same automated distribution tool, though, and so remain related projects. The key difference between PEAR modules and PECL modules: PEAR modules are written inPHP, and may be included in PHP programs as required. PECL modules are written in C, andmay be incorporated into the PHP engine itself by the normal process of recompiling. The PEAR Package SystemThe PEAR package system is an archive of compressed files (tar files compressed with gzip), each of which contains a series of PHP files and a manifest file in XML format. Each archive, when incorporated into a PHP installation on a server (by means of the automated package- management system that s discussed later in this chapter), adds to the overall collection offunctions and classes a developer can invoke in his or her code. Widely used packages handledatabase abstraction, the interpretation of various file formats, the implementation of indus- try-specific algorithms, and all kinds of convenience functions. The universe of PEAR pack- ages is large and expanding, and because the packages are of such high quality you shouldmake use of them in your own code if you can. The PEAR homepage is http://pear.php.net. A sampling of PEAR packagesHere s a much-abridged list of PEAR packages. The package name generally describes itsfunction:
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision make web site services

PEARThe PHP Extension and Application Repository (PEAR) is (Web design templates)

Thursday, April 26th, 2007

PEARThe PHP Extension and Application Repository (PEAR) is a broadeffort with many component parts, collectively aimed at expand- ing the usefulness and reliability of the PHP language. With PEAR, developers should be able to write more capable software morequickly and with greater reliability. The most useful and best-known element of PEAR, its package- management system, attempts to reduce the frequency with whichPHP developers reinvent the wheel. Its main part is an onlinedatabase of code modules, accessible to anyone via an automatedprocess, that give the PHP language special capabilities. PEAR mod- ules, for example, enable PHP programmers to access LDAP directo- ries and open files in the Ogg Vorbis format without writing utilityclasses for those jobs. Programmers using the PEAR packages canfocus on the functionality of their creations, rather than wasting timestruggling with nuts-and-bolts problems. The PEAR initiative also includes a set of rules about how code is tobe written a style guide, if you like. The PEAR coding style rules aremeant to govern modules contributed to the PEAR archive, but in factapply well to all PHP work. You could do worse than to apply thePEAR coding style rules to all your PHP programs. PEAR has a sister project, the PHP Extension Community Library(PECL, pronounced pickle). PECL modules are extensions to PHPitself, rather than just PHP modules that can be imported into PHPprograms as needed. Together, PEAR and PECL make PHP muchmore capable and enable many more people to participate in thedevelopment of the language. What Is PEAR? There are many common tasks in PHP that require or strongly benefitfrom libraries of functions. There are many Web sites where PHPcommunity members offer code they ve written, but how do youknow the code is good, will be maintained and extended, and doesn thave any odd quirks or even malicious features? The PEAR projectoffers a large and growing library of known-good, well-maintained, well- documented PHP code which has passed many quality inspections all free for the taking. 2828CHAPTER …In This ChapterWhat is PEAR? The PEAR packagesystemPHP Foundation Classes (PFC) PHP Extension CodeLibrary (PECL) The PEAR coding style …
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision ecommerce web hosting services

516Part IIIAdvanced Features and TechniquesTable 27-6(continued) CategoryDescriptionExponential functionsFunctions (Cheap web hosting)

Thursday, April 26th, 2007

516Part IIIAdvanced Features and TechniquesTable 27-6(continued) CategoryDescriptionExponential functionsFunctions having to do with raising numbers to powers or theinverse: log() (natural log), log10()(base-10 log), exp() (eraised to the power of the argument), and pow()(firstargument to the power of the second). Trigonometric functionsFunctions having to do with angular measures: pi()(and theequivalent constant M_PI), sin(), cos(), tan(), acos(), asin(),atan(), and atan2()(a two-argument version ofatan()). Arbitrary-precision (BC) functionsFunctions that do arithmetic on arbitrary-length stringsrepresenting decimal integers and floating-point numbers: bdadd(), bcsub(), bcmult(), bcdiv(), bcmod(), bcpow(), bcsqrt(). Most of these functions take anoptional scale parameter specifying the number of decimalpoints of precision desired the default for that parameter issettable using bcscale(). …
Note: In case you are looking for affordable and reliable webhost to host and run your business application check Vision ftp web hosting services

515Chapter 27MathematicsSomewhat more satisfyingly, evaluating: print( The square (Web design templates) root

Thursday, April 26th, 2007

515Chapter 27MathematicsSomewhat more satisfyingly, evaluating: print( The square root of two is . bcsqrt(2, 40)); gives us many more digits of precision than we could get using doubles: The square root of two is 1.4142135623730950488016887242096980785696SummaryAlthough the primary purpose of PHP is not to do mathematics, it has a pretty comprehen- sive set of mathematical functions covering basic arithmetic, pseudo-random number genera- tion, base conversion, trigonometry, exponents and logarithms, and a built-in module fordoing arbitrary-precision arithmetic. We covered the numerical types and the most basic functions in Chapter 10, and covered theremaining topics in this chapter. Table 27-6 is a tabular summary of the operators and func- tions discussed both in Chapter 10 and this chapter. Table 27-6: Summary of PHP Math Operators and FunctionsCategoryDescriptionArithmetic operatorsOperators +, -, *, /, %perform basic arithmetic on integers anddoubles. Incrementing operatorsThe ++and –operators change the values of numericalvariables, increasing them by one or decreasing them by one(respectively). The value of the postincrement form ($var++) is the same as the variable s value before the change; the valueof the preincrement form (++$var) is the variable s value afterthe change. Assignment operatorsEach arithmetic operator (like +) has a correspondingassignment operator (+=). The expression $count += 5isequivalent to $count = $count + 5. Comparison operatorsThese operators (<, <=,>, >=, ==, !=) compare two numbersand return either trueor false. The ===operator is true ifand only if its arguments are equal and of the same type. Basic math functionsfloor(), ceil(), and round() convert doubles to integers, min()and max()take the minimum and maximum of theirnumerical arguments, and abs()is the absolute value function. Base conversion functionsSpecial-purpose functions (OctDec(), DecOct(), BinDec(), DecBin(), HexDec(),DecHex()) convert betweenparticular pairs of bases, whereas base_convert()translatesbetween arbitrary bases. Continued31
Note: If you are looking for reliable webhost to maintain and run your java application check Vision java hosting services

514Part IIIAdvanced (Ftp web hosting) Features and TechniquesTo convert this to

Wednesday, April 25th, 2007

514Part IIIAdvanced Features and TechniquesTo convert this to an arbitrary-precision version, we must replace all the math functions andoperators that need precision with their BC counterparts, like so: function pi_approx_bc($iterations, $print_frequency, $scale) { $squared_approx = 12 ; $next_sign = -1; $denom = 2; for ($iter = 0; $iter < $iterations; $iter++) { $squared_approx = bcadd( $squared_approx, bcmul($next_sign, bcdiv(12, bcpow($denom, 2, $scale), $scale), $scale), $scale); $denom++; $next_sign = - $next_sign; if ($denom % $print_frequency == 0) { $estimate = bcsqrt($squared_approx,$scale); print( $denom iterations: $estimate
); } } } Notice that although the BC functions want string arguments, we can as always use regularnumbers in their places and rely on PHP to convert the arguments to strings for us. Also noticethat we did not bother making the numerical computations that do not require great precisioninto BC computations (for instance, we still have $denom++rather than bcadd($denom,1). Finally, we added a scale argument to the entire function, which turns the decimal precision ofeach BC function it calls. Unfortunately, both your authors and our browsers ran out of patience with this series beforeit got even got to the level of precision of PHP s value. Here are some late results of callingpi_approx_bc(1250000,50000,50): 50000 iterations: 3.14159265397177274129723551068347726371297686926596100000 iterations: 3.14159265368528715924598769254390594927146205337113150000 iterations: 3.14159265363223483956231649503922204272933217538202[..] 1150000 iterations: 3.141592653590515303104552554096025800032655499550031200000 iterations: 3.141592653590456384611480874034589189444055471472111250000 iterations: 3.14159265359040439393304018710072157703501022388304The correct digits in the preceding output are about one digit shy of the PHP value. This isthe fault of the series we chose rather than the arbitrary-precision libraries with a moresophisticated and speedier approximation series, you too can serve up millions of digits of pito your eager audience.
Note: If you are looking for cheap and reliable webhost to host and run your web application check Vision coldfusion web hosting services

513Chapter 27MathematicsConverting code to arbitrary-precisionLet s see what it s (Crystaltech web hosting)

Wednesday, April 25th, 2007

513Chapter 27MathematicsConverting code to arbitrary-precisionLet s see what it s like to take an existing piece of mathematical code and retrofit it to use thearbitrary-precision functions. The following function approximates pi, using the series approximation: sqrt ( 12 - (12/22) + (12/32) - (12/42) + (12/52) - …) (As we ll see, this series does not converge fast enough for our purposes, but it has the virtueof being a simple formula.) function pi_approx($iterations, $print_frequency) { $squared_approx = 12; $next_sign = -1; $denom = 2; for ($iter = 0; $iter < $iterations; $iter++) { $squared_approx += $next_sign * 12/(pow($denom,2)); $denom++; $next_sign = - $next_sign; if ($denom % $print_frequency == 0) { $estimate = sqrt($squared_approx); print( $denom iterations: $estimate
); } } } In addition to performing the calculation itself, this code periodically prints its current esti- mate of pi, so we can see how we are doing. We can call it as follows and then print PHP svalue for comparison: pi_approx(10000, 1000); print( PHP value: . pi() .
); The result looks like: 1000 iterations: 3.14159360947422000 iterations: 3.14159289244163000 iterations: 3.14159275972854000 iterations: 3.14159271328785000 iterations: 3.14159269179466000 iterations: 3.141592680127000 iterations: 3.1415926730818000 iterations: 3.14159266851249000 iterations: 3.141592665380410000 iterations: 3.1415926631401PHP value: 3.1415926535898Now, not only are we not that close, but we can t hope to be more accurate than PHP s valuefor pi, because that already uses all the precision available in the double type.
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision tomcat hosting services