From a72ff04d75a985d3dc7bde0a12dd2fd6dca5854b Mon Sep 17 00:00:00 2001 From: Hartmut Holzgraefe Date: Tue, 1 May 2001 16:20:51 +0000 Subject: [PATCH] floor/ceil return type was not up to the code git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@46284 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/math.xml | 56 ++++++++++++---------------- functions/pgsql.xml | 22 +++++++++++ functions/session.xml | 85 ++++++++++++++++++++++++++++++++++++++++++- functions/strings.xml | 18 +++++++-- 4 files changed, 143 insertions(+), 38 deletions(-) diff --git a/functions/math.xml b/functions/math.xml index ca3c937a7f..79e26f9db6 100644 --- a/functions/math.xml +++ b/functions/math.xml @@ -138,7 +138,9 @@ Returns the absolute value of number. If the argument number is - float, return type is also float, otherwise it is int. + of type float, the return type is also float, + otherwise it is int (as float usually has a + bigger value range than int). @@ -314,25 +316,16 @@ $binary = base_convert ($hexadecimal, 16, 2); Description - int ceil - float number + float ceil + float value - - Returns the next highest integer value from - number. Using ceil - on integers is absolutely a waste of time. - - -$x = ceil(4.25); -// which would make $x=5 - - - - NOTE: PHP/FI 2's ceil returned a - float. Use: $new = (double)ceil($number); to - get the old behaviour. + Returns the next highest integer value by rounding up + value if necessary. + The return value of ceil is still of type + float as the value range of float is + usually bigger than that of int. See also floor and @@ -491,19 +484,16 @@ $x = ceil(4.25); Description - int floor - float number + float floor + float value - Returns the next lowest integer value from - number. Using floor - on integers is absolutely a waste of time. - - - NOTE: PHP/FI 2's floor returned a - float. Use: $new = (double)floor($number); to - get the old behaviour. + Returns the next lowest integer value by rounding down + value if neccessary. + The return value of ceil is still of type + float as the value range of float is + usually bigger than that of int. See also ceil and @@ -1026,12 +1016,12 @@ $foo = round (1.95583, 2); // $foo == 1.96 - - - The precision parameter is only - available in PHP 4. - - + + + The precision parameter is only + available in PHP 4. + + See also ceil and floor. diff --git a/functions/pgsql.xml b/functions/pgsql.xml index ac07d857a3..fe15bbe92e 100644 --- a/functions/pgsql.xml +++ b/functions/pgsql.xml @@ -40,6 +40,7 @@ postmaster -i & + pg_connect("dbname=MyDbName"); OK @@ -171,6 +172,27 @@ echo $cmdtuples . " <- cmdtuples affected."; Description + + int pg_connect + string host + string port + string dbname + + + int pg_connect + string host + string port + string options + string dbname + + + int pg_connect + string host + string port + string options + string tty + string dbname + int pg_connect string conn_string diff --git a/functions/session.xml b/functions/session.xml index d4e82b08b0..44489fd9bc 100644 --- a/functions/session.xml +++ b/functions/session.xml @@ -136,6 +136,8 @@ $count++; The following example demonstrates how to register a variable, and how to link correctly to another page using SID. + + Counting the number of hits of a single user @@ -147,17 +149,94 @@ $count++; Hello visitor, you have seen this page <?php echo $count; ?> times.<p> <php? -# the <?=SID?> is necessary to preserve the session id +# the <?php echo SID;?> is necessary to preserve the session id # in the case that the user has disabled cookies ?> -To continue, <A HREF="nextpage.php?<?=SID?>">click here</A> +To continue, <A HREF="nextpage.php?<?php echo SID;?>">click here</A> + To implement database storage you need PHP code and a user level + function session_set_save_handler. You would + have to extend the following functions to cover MySQL or another + database. + + +<<<<<<< session.xml + + + Usage of <function>session_set_save_handler</function> + + +<?php + +function open ($save_path, $session_name) { + echo "open ($save_path, $session_name)\n"; + return true; +} + +function close() { + echo "close\n"; + return true; +} + +function read ($key) { +<<<<<<< session.xml + echo "read ($key, $val)\n"; +======= + echo "read ($key)\n"; +>>>>>>> 1.19 + return "foo|i:1;"; +} + +function write ($key, $val) { + echo "write ($key, $val)\n"; + return true; +} + +function destroy ($key) { + return true; +} + +function gc ($maxlifetime) { + return true; +} + +session_set_save_handler ("open", "close", "read", "write", "destroy", "gc"); + +session_start(); + +$foo++; + +?> + + + + + Will produce this results: + + + +$ ./php save_handler.php +Content-Type: text/html +Set-cookie: PHPSESSID=f08b925af0ecb52bdd2de97d95cdbe6b + +open (/tmp, PHPSESSID) +read (f08b925af0ecb52bdd2de97d95cdbe6b) +write (f08b925af0ecb52bdd2de97d95cdbe6b, foo|i:2;) +close + +======= The <?=SID?> is not necessary, if --enable-trans-sid was used to compile PHP. +>>>>>>> 1.23 + + +<<<<<<< session.xml + The <?php echo SID;?> is not necessary, if + --enable-trans-sid was used to compile PHP. @@ -167,11 +246,13 @@ To continue, <A HREF="nextpage.php?<?=SID?>">click here</A> +======= To implement database storage, or any other storage method, you will need to use session_set_save_handler to create a set of user-level storage functions. +>>>>>>> 1.23 The session management system supports a number of configuration options which you can place in your php.ini file. We will give a short overview. diff --git a/functions/strings.xml b/functions/strings.xml index 7c8b5d6db7..db389c2b2d 100644 --- a/functions/strings.xml +++ b/functions/strings.xml @@ -3426,15 +3426,27 @@ $text = ucfirst ($text); // $text is now Mary had a little lamb +<<<<<<< strings.xml +<<<<<<< strings.xml + Capitalizes the first character of each word in + str if that character is alphabetic. A + word is defined as any sequence of non-whitespace letters (of the + current locale) immediately following a whitespace (space, + horizontal or vertical tab, linefeed or carriage return). +======= + Retuns a string with the first character of each word in +======= Returns a string with the first character of each word in +>>>>>>> 1.83 str capitalized, if that character is alphabetic. +>>>>>>> 1.77 <function>ucwords</function> example -$text = "mary had a little lamb and she loved it so."; -$text = ucwords($text); // $text is now: Mary Had A Little - // Lamb And She Loved It So. +$text = "mary had a little lamb and she loved it so."; $text = + ucwords($text); // $text is now: Mary Had A Little // Lamb And + She Loved It So.