Php manual 1224517992
69 pages
Français

Découvre YouScribe en t'inscrivant gratuitement

Je m'inscris

Php manual 1224517992

-

Découvre YouScribe en t'inscrivant gratuitement

Je m'inscris
Obtenez un accès à la bibliothèque pour le consulter en ligne
En savoir plus
69 pages
Français
Obtenez un accès à la bibliothèque pour le consulter en ligne
En savoir plus

Sujets

Informations

Publié par
Nombre de lectures 145
Langue Français

Extrait

What is PHP? PHP (recursive acronym for "PHP: Hypertext Preprocessor") is a widely­used Open Source general­purpose   scripting language that is especially suited for Web development and can be embedded into HTML.  Example 1­1. An introductory example Example Notice how this is different from a script written in other languages like Perl or C ­­ instead of writing a   program with lots of commands to output HTML, you write an HTML script with some embedded code to do   something (in this case, output some text). The PHP code is enclosed in special  start and end tags that allow  you to jump into and out of "PHP mode".  What distinguishes PHP from something like client­side JavaScript is that the code is executed on the server.   If you were to have a script similar to the above on your server, the client would receive the results of running   that script, with no way of determining what the underlying code may be. You can even configure your web   server to process all your HTML files with PHP, and then there's really no way that users can tell what you   have up your sleeve.  The best things in using PHP are that it is extremely simple for a newcomer, but offers many advanced   features for a professional programmer. Don't be afraid reading the long list of PHP's features. You can jump   in, in a short time, and start writing simple scripts in a few hours.  What can PHP do? Anything. PHP is mainly focused on server­side scripting, so you can do anything any other CGI program can   do, such as collect form data, generate dynamic page content, or send and receive cookies. But PHP can do   much more.  There are three main areas where PHP scripts are used.   Server­side scripting. This is the most traditional and main target field for PHP. You need three things to   make this work. The PHP parser (CGI or server module), a webserver and a web browser. You need to   run the webserver, with a connected PHP installation. You can access the PHP program output with a   web browser, viewing the PHP page through the server. All these can run on your home machine if you  are just experimenting with PHP programming.   Command line scripting. You can make a PHP script to run it without any server or browser. You only   need the PHP parser to use it this way. This type of usage is ideal for scripts regularly executed using   cron (on *nix or Linux) or Task Scheduler (on Windows). These scripts can also be used for simple text   processing tasks.   Writing desktop applications. PHP is probably not the very best language to create a desktop application   with a graphical user interface, but if you know PHP very well, and would like to use some advanced PHP  features in your client­side applications you can also use PHP­GTK to write such programs. You also   have the ability to write cross­platform applications this way. PHP­GTK is an extension to PHP, not   available in the main distribution.  Page 1 of  69 PHP can be used on all major operating systems, including Linux, many Unix variants (including HP­UX,   Solaris and OpenBSD), Microsoft Windows, Mac OS X, RISC OS, and probably others. PHP has also support   for most of the web servers today. This includes Apache, Microsoft Internet Information Server, Personal Web   Server, Netscape and iPlanet servers, Oreilly Website Pro server, Caudium, Xitami, OmniHTTPd, and many  others. For the majority of the servers PHP has a module, for the others supporting the CGI standard, PHP   can work as a CGI processor.  So with PHP, you have the freedom of choosing an operating system and a web server. Furthermore, you  also have the choice of using procedural programming or object oriented programming, or a mixture of them.  Although not every standard OOP feature is implemented in PHP 4, many code libraries and large   applications (including the PEAR library) are written only using OOP code. PHP 5 fixes the OOP related   weaknesses of PHP 4, and introduces a complete object model.  With PHP you are not limited to output HTML. PHP's abilities includes outputting images, PDF files and even   Flash movies (using libswf and Ming) generated on the fly. You can also output easily any text, such as   XHTML and any other XML file. PHP can autogenerate these files, and save them in the file system, instead   of printing it out, forming a server­side cache for your dynamic content.  One of the strongest and most significant features in PHP is its support for a wide range of databases. Writing   a database­enabled web page is incredibly simple. The following databases are currently supported:  Adabas D InterBase PostgreSQL dBase FrontBase SQLite Empress mSQL Solid FilePro (read­only) Direct MS­SQL Sybase Hyperwave MySQL Velocis IBM DB2 ODBC Unix dbm Informix Oracle (OCI7 and OCI8)   Ingres Ovrimos   We also have a database abstraction extension (named PDO) allowing you to transparently use any database   supported by that extension. Additionally PHP supports ODBC, the Open Database Connection standard, so   you can connect to any other database supporting this world standard.  PHP also has support for talking to other services using protocols such as LDAP, IMAP, SNMP, NNTP,   POP3, HTTP, COM (on Windows) and countless others. You can also open raw network sockets and interact   using any other protocol. PHP has support for the WDDX complex data exchange between virtually all Web   programming languages. Talking about interconnection, PHP has support for instantiation of Java objects and   using them transparently as PHP objects. You can also use our CORBA extension to access remote objects.  PHP has extremely useful text processing features, from the POSIX Extended or Perl regular expressions to   parsing XML documents. For parsing and accessing XML documents, PHP 4 supports the SAX and DOM   standards, and you can also use the XSLT extension to transform XML documents. PHP 5 standardizes all   the XML extensions on the solid base of libxml2 and extends the feature set adding SimpleXML and   XMLReader support.  Page 2 of  69 BASIC SYNTAX Escaping from HTML When PHP parses a file, it looks for opening and closing tags, which tell PHP to start and stop interpreting the   code between them. Parsing in this manner allows php to be embedded in all sorts of different documents, as   everything outside of a pair of opening and closing tags is ignored by the PHP parser. Most of the time you   will see php embedded in HTML documents, as in this example. 

This is going to be ignored.

This will also be ignored.

You can also use more advanced structures:  Example 10­1. Advanced escaping This is true. This is false. This works as expected, because when PHP hits the ?> closing tags, it simply starts outputting whatever it   finds until it hits another opening tag. The example given here is contrived, of course, but for outputting large   blocks of text, dropping out of PHP parsing mode is generally more efficient than sending all of the text   through echo() or print().  There are four different pairs of opening and closing tags which can be used in php. Two of those,    and  , are always available. The other two are short tags and  ASP style tags,  and can be turned on and off from the php.ini configuration file. As such, while some people find short tags   and ASP style tags convenient, they are less portable, and generally not recommended.  Example 10­2. PHP Opening and Closing Tags 1. 2. 3. This is a shortcut for "" 4. <% echo 'You may optionally use ASP-style tags'; %> <%= $variable; # This is a shortcut for "<% echo . . ." %> While the tags seen in examples one and two are both always available, example one is the most commonly   used, and recommended, of the two.  Instruction separation Page 3 of  69 As in C or Perl, PHP requires instructions to be terminated with a semicolon at the end of each statement. The   closing tag of a block of PHP code automatically implies a semicolon; you do not need to have a semicolon   terminating the last line of a PHP block. The closing tag for the block will include the immediately trailing   newline if one is present.  The "one­line" comment styles only comment to the end of the line or the current block of PHP code,   whichever comes first. This means that HTML code after  // ... ?> or # ... ?> WILL be printed: ?> breaks out of   PHP mode and returns to HTML mode, and  // or # cannot influence that. If the asp_tags co
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents