CVS update: php3/doc/chapters

From: Date: Thu, 10 Dec 1998 02:07:30 +0000
Subject: CVS update: php3/doc/chapters
Groups: php.dev 
Request: Send a blank email to php-dev+get-2730@lists.php.net to get a copy of this message
Date: Wednesday December 9, 1998 @ 21:07 Author: jim Update of /repository/php3/doc/chapters In directory asf:/u/temp/cvs-serv5033/chapters Modified Files: config.sgml features.sgml install.sgml lang-const.sgml lang-syntax.sgml Log Message: More revisions from the errata. Index: php3/doc/chapters/config.sgml diff -c php3/doc/chapters/config.sgml:1.42 php3/doc/chapters/config.sgml:1.43 *** php3/doc/chapters/config.sgml:1.42 Wed Dec 9 12:09:54 1998 --- php3/doc/chapters/config.sgml Wed Dec 9 21:07:25 1998 *************** *** 1326,1335 **** <sect2 id="config-security-apache"> <title>Apache module</title> <simpara> ! When PHP is used as an Apache module it inherits Apache's ! security setup. A request for a file will have to go through ! Apache's regular checks and only if these are passed successfully ! does the request make it way to PHP. </sect2> --- 1326,1333 ---- <sect2 id="config-security-apache"> <title>Apache module</title> <simpara> ! When PHP is used as an Apache module it inherits Apache's user ! permissions (typically those of the "nobody" user). </sect2> Index: php3/doc/chapters/features.sgml diff -c php3/doc/chapters/features.sgml:1.19 php3/doc/chapters/features.sgml:1.20 *** php3/doc/chapters/features.sgml:1.19 Mon Dec 7 22:10:15 1998 --- php3/doc/chapters/features.sgml Wed Dec 9 21:07:27 1998 *************** *** 44,59 **** <emphasis>WWW-Authenticate</emphasis> header before the <errorcode>HTTP/1.0 401</errorcode> header seems to do the trick for now. ! <para> In order to prevent someone from writing a script which reveals the password for a page that was authenticated through a traditional external mechanism, the PHP_AUTH variables will not be set if external authentication is enabled for that particular ! page. ! <para> Note, however, that the above does not prevent someone who controls a non-authenticated URL from stealing passwords from authenticated URLs on the same server. <sect1 id="feature-images"> <title>GIF creation with PHP</title> --- 44,75 ---- <emphasis>WWW-Authenticate</emphasis> header before the <errorcode>HTTP/1.0 401</errorcode> header seems to do the trick for now. ! <simpara> In order to prevent someone from writing a script which reveals the password for a page that was authenticated through a traditional external mechanism, the PHP_AUTH variables will not be set if external authentication is enabled for that particular ! page. In this case, the $REMOTE_USER variable can be used to ! identify the externally-authenticated user. ! <simpara> Note, however, that the above does not prevent someone who controls a non-authenticated URL from stealing passwords from authenticated URLs on the same server. + <simpara> + Both Netscape and Internet Explorer will clear the local browser window's + authentication cache for the realm upon receiving a server response of 401. This + can effectively "log out" a user, forcing them to re-enter their username and + password. Some people use this to "time out" logins, or provide a "log-out" + button. + <simpara> + This behavior is not required by the HTTP Basic authentication standard, so you + should never depend on this. Testing with Lynx has shown that Lynx does not clear + the authentication credentials with a 401 server response, so pressing back and + then forward again will open the resource (as long as the credential requirements + haven't changed). + <simpara> + Also note that this does not work using Microsoft's IIS server + and the CGI version of PHP due to a limitation of IIS. <sect1 id="feature-images"> <title>GIF creation with PHP</title> *************** *** 249,281 **** <example> <title>Regular expression examples</title> <programlisting> ! ereg(&quot;abc&quot;,$string); /* Returns true if &quot;abc&quot; ! is found anywhere in $string. */ ! ! ereg(&quot;^abc&quot;,$string); /* Returns true if &quot;abc&quot; is ! found at the beginning of $string. */ ! ! ereg("abc$",$string); /* Returns true if &quot;abc&quot; ! is found at the end of $string. */ eregi("(ozilla.[23]|MSIE.3)",$HTTP_USER_AGENT); ! /* Returns true if client browser ! is Netscape 2, 3 or MSIE 3. */ ! ereg("([[:alnum:]]+) ([[:alnum:]]+) ([[:alnum:]]+)",$string,$regs); ! /* Places three space separated words ! into $regs[1], $regs[2] and $regs[3]. */ ereg_replace("^","&lt;BR&gt;",$string); ! /* Put a &lt;BR&gt; tag at ! the beginning of $string. */ ereg_replace("$","&lt;BR&gt;",$string); ! /* Put a &lt;BR&gt; tag ! at the end of $string. */ ! ereg_replace("\n","",$string); /* Get rid of any carriage return ! characters in $string. */ </programlisting></example> </para> --- 265,300 ---- <example> <title>Regular expression examples</title> <programlisting> ! ereg(&quot;abc&quot;,$string); ! /* Returns true if &quot;abc&quot; ! is found anywhere in $string. */ ! ! ereg(&quot;^abc&quot;,$string); ! /* Returns true if &quot;abc&quot; ! is found at the beginning of $string. */ ! ! ereg("abc$",$string); ! /* Returns true if &quot;abc&quot; ! is found at the end of $string. */ eregi("(ozilla.[23]|MSIE.3)",$HTTP_USER_AGENT); ! /* Returns true if client browser ! is Netscape 2, 3 or MSIE 3. */ ! ereg("([[:alnum:]]+) ([[:alnum:]]+) ([[:alnum:]]+)", ! $string,$regs); ! /* Places three space separated words ! into $regs[1], $regs[2] and $regs[3]. */ ereg_replace("^","&lt;BR&gt;",$string); ! /* Put a &lt;BR&gt; tag at the beginning of $string. */ ereg_replace("$","&lt;BR&gt;",$string); ! /* Put a &lt;BR&gt; tag at the end of $string. */ ! ereg_replace("\n","",$string); ! /* Get rid of any carriage return ! characters in $string. */ </programlisting></example> </para> Index: php3/doc/chapters/install.sgml diff -c php3/doc/chapters/install.sgml:1.32 php3/doc/chapters/install.sgml:1.33 *** php3/doc/chapters/install.sgml:1.32 Sat Nov 28 13:17:45 1998 --- php3/doc/chapters/install.sgml Wed Dec 9 21:07:27 1998 *************** *** 39,45 **** 5. cd apache_1.3.x 6. ./configure --prefix=/www 7. cd ../php-3.0.x ! 8. ./configure --with-mysql --with-apache=../apache_1.3.x --enable-track-vars 9. make 10. make install 11. cd ../apache_1.3.x --- 39,45 ---- 5. cd apache_1.3.x 6. ./configure --prefix=/www 7. cd ../php-3.0.x ! 8. ./configure --with-mysql=/usr/local/mysql --with-apache=../apache_1.3.x --enable-track-vars 9. make 10. make install 11. cd ../apache_1.3.x *************** *** 60,66 **** You can choose any extension you wish here. .php3 is simply the one we suggest. ! 18. Use your normal procedure for starting the Apache server. </programlisting> </informalexample> --- 60,68 ---- You can choose any extension you wish here. .php3 is simply the one we suggest. ! 18. Use your normal procedure for starting the Apache server. (You must ! stop and restart the server, not just cause the server to reload by ! use a HUP or USR1 signal.) </programlisting> </informalexample> Index: php3/doc/chapters/lang-const.sgml diff -c php3/doc/chapters/lang-const.sgml:1.28 php3/doc/chapters/lang-const.sgml:1.29 *** php3/doc/chapters/lang-const.sgml:1.28 Mon Dec 7 22:11:11 1998 --- php3/doc/chapters/lang-const.sgml Wed Dec 9 21:07:28 1998 *************** *** 2,8 **** <title>Language constructs</title> <simpara> ! Any PHP 3 script is built out of a series of statements. A statement can be an assignment, a function call, a loop, a conditional statement of even a statement that does nothing (an empty statement). Statements usually end with a semicolon. In --- 2,8 ---- <title>Language constructs</title> <simpara> ! Any PHP script is built out of a series of statements. A statement can be an assignment, a function call, a loop, a conditional statement of even a statement that does nothing (an empty statement). Statements usually end with a semicolon. In *************** *** 12,22 **** statement types are described in this chapter. </simpara> <sect1 id="expressions"> <title>Expressions</title> <simpara> ! Expressions are the most important building stones of PHP. In PHP ! 3.0, almost anything you write is an expression. The simplest yet most accurate way to define an expressions is "anything that has a value". <simpara> --- 12,56 ---- statement types are described in this chapter. </simpara> + <sect1 id="constants"> + <title>Constants</title> + <simpara> + PHP defines a few constants and provides a mechanism for defining + more at run-time. Constants are much like variables, but they have + a slightly different syntax. + <para> + The pre-defined constants are __FILE__ and __LINE__, which + correspond to the filename and line number being processed when + they are encountered. + <example><title>Using __FILE__ and __LINE__</title> + <programlisting> + &lt;?php + function report_error($file, $line, $message) { + echo "An error occured in $file on line $line: $message."; + } + + report_error(__FILE__,__LINE__, "Something went wrong!"); + ?&gt; + </programlisting> + </example> + <para> + You can define additional constants using the <function>define</function> + and <function>undefine</function> functions. + <example><title>Defining Constants</title> + <programlisting> + &lt;?php + define("CONSTANT", "Hello world."); + echo CONSTANT; // outputs "Hello world." + undefine ("CONSTANT"); + ?&gt; + </programlisting> + </example> + <sect1 id="expressions"> <title>Expressions</title> <simpara> ! Expressions are the most important building stones of PHP. In PHP, ! almost anything you write is an expression. The simplest yet most accurate way to define an expressions is "anything that has a value". <simpara> *************** *** 53,59 **** <simpara> Of course, values in PHP don't have to be integers, and very often ! they aren't. PHP supports 3 scalar value types: integer values, floating point values and string values (scalar values are values that you can't 'break' into smaller pieces, unlike arrays, for instance). PHP also supports two composite (non-scalar) types: arrays and --- 87,93 ---- <simpara> Of course, values in PHP don't have to be integers, and very often ! they aren't. PHP supports three scalar value types: integer values, floating point values and string values (scalar values are values that you can't 'break' into smaller pieces, unlike arrays, for instance). PHP also supports two composite (non-scalar) types: arrays and *************** *** 180,191 **** contains no elements it's considered FALSE, otherwise it's considered TRUE. <simpara> ! PHP provides a full and powerful implementation of expressions, ! and documenting it entirely goes beyond the scope of this manual. ! The above examples should give you a good idea about what ! expressions are and how you can construct useful expressions. ! Throughout the rest of this manual we'll write 'expr' to indicate any ! valid PHP3 expression. <sect1 id="construct.if"> <title>IF</title> --- 214,225 ---- contains no elements it's considered FALSE, otherwise it's considered TRUE. <simpara> ! PHP provides a full and powerful implementation of expressions, and ! documenting it entirely goes beyond the scope of this manual. The ! above examples should give you a good idea about what expressions ! are and how you can construct useful expressions. Throughout the ! rest of this manual we'll write 'expr' to indicate any valid PHP ! expression. <sect1 id="construct.if"> <title>IF</title> *************** *** 360,366 **** /* example 1 */ $i=1; while ($i<=10) { ! print $i++; /* the printed value would be $i before the increment (post-increment) */ } /* example 2 */ --- 394,402 ---- /* example 1 */ $i=1; while ($i<=10) { ! print $i++; /* the printed value would be ! $i before the increment ! (post-increment) */ } /* example 2 */ *************** *** 498,503 **** --- 534,568 ---- and <function>each</function> functions for this. See the documentation for these functions for an example. + <sect1 id="construct.break"> + <title>BREAK</title> + + <para> + BREAK breaks out of the current looping construct. + <informalexample><programlisting> + $i = 0; + while ($i < 10) { + if ($arr[$i] == "stop") { + break; + } + $i++; + } + </programlisting></informalexample> + + <sect1 id="construct.continue"> + <title>CONTINUE</title> + + <para> + CONTINUE jumps to the beginning of enclosing the looping construct. + <informalexample><programlisting> + while (list($key,$value) = each($arr)) { + if ($key % 2) { // skip even members + continue; + } + do_something_odd($value); + } + </programlisting></informalexample> + <sect1 id="construct.switch"> <title>SWITCH</title> *************** *** 613,619 **** <sect1 id="function.include"> <title>INCLUDE</title> <simpara> ! The INCLUDE statement includes the specified file. <para> This happens each time the INCLUDE statement is encountered, so you can use an INCLUDE statement within a looping structure --- 678,684 ---- <sect1 id="function.include"> <title>INCLUDE</title> <simpara> ! The INCLUDE statement includes and evaluates the specified file. <para> This happens each time the INCLUDE statement is encountered, so you can use an INCLUDE statement within a looping structure *************** *** 624,629 **** --- 689,725 ---- include($files[$i]); } </programlisting></informalexample> + <para> + <function>include</function> differs from <function>require</function> in that the + include statement is re-evaluated each time it is encountered (and only when it is + being executed), whereas the <function>require</function> statement is replaced by + the required file when it is first encountered, whether the contents of the file + will be evaluated or not (for example, if it is inside an if statement whose + condition evaluated to false). + <para> + Because <function>include</function> is a special language construct, you + must enclose it within a statement block if it is inside a conditional + block. + <informalexample><programlisting> + /* This is WRONG and will not work as desired. */ + if ($condition) + include($file); + else + include($other); + + /* This is CORRECT. */ + if ($condition) { + include($file); + } else { + include($other); + } + </programlisting></informalexample> + <para> + When the file is evaluated, the parser beings in "HTML-mode" which will + output the contents of the file until the first PHP start tag (&lt;?) + is encountered. + <para> + See also <function>readfile</function>, <function>virtual</function>. <sect1 id="keyword.function"> <title>FUNCTION</title> Index: php3/doc/chapters/lang-syntax.sgml diff -c php3/doc/chapters/lang-syntax.sgml:1.25 php3/doc/chapters/lang-syntax.sgml:1.26 *** php3/doc/chapters/lang-syntax.sgml:1.25 Mon Dec 7 22:11:27 1998 --- php3/doc/chapters/lang-syntax.sgml Wed Dec 9 21:07:30 1998 *************** *** 33,40 **** <sect1 id="syntax-instrsep"> <title>Instruction separation</title> ! <simpara></simpara> <sect1 id="variable-types"> <title>Variable types</title> --- 33,51 ---- <sect1 id="syntax-instrsep"> <title>Instruction separation</title> ! <simpara> ! Instructions are separated the same as in C or perl - terminate each statement ! with a semicolon. ! <para> ! The closing tag (?&gt;) also implies the end of the statement, so the ! following are equivalent: ! <informalexample><programlisting> ! <?php ! echo "This is a test; ! ?> + <?php echo "This is a test" ?> + </programlisting></informalexample> <sect1 id="variable-types"> <title>Variable types</title> *************** *** 249,254 **** --- 260,266 ---- if($count < 10) { Test(); } + $count--; } </programlisting></informalexample> -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#2730) next »