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
This commit is contained in:
Hartmut Holzgraefe 2001-05-01 16:20:51 +00:00
parent 68397441e4
commit a72ff04d75
4 changed files with 143 additions and 38 deletions

View file

@ -138,7 +138,9 @@
</funcsynopsis>
<para>
Returns the absolute value of number. If the argument number is
float, return type is also float, otherwise it is int.
of type <type>float</type>, the return type is also <type>float</type>,
otherwise it is <type>int</type> (as <type>float</type> usually has a
bigger value range than <type>int</type>).
</para>
</refsect1>
</refentry>
@ -314,25 +316,16 @@ $binary = base_convert ($hexadecimal, 16, 2);
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>ceil</function></funcdef>
<paramdef>float <parameter>number</parameter></paramdef>
<funcdef>float <function>ceil</function></funcdef>
<paramdef>float <parameter>value</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
Returns the next highest integer value from
<parameter>number</parameter>. Using <function>ceil</function>
on integers is absolutely a waste of time.
<informalexample>
<programlisting role="php">
$x = ceil(4.25);
// which would make $x=5
</programlisting>
</informalexample>
</para>
<simpara>
NOTE: PHP/FI 2's <function>ceil</function> returned a
float. Use: <literal>$new = (double)ceil($number);</literal> to
get the old behaviour.
Returns the next highest integer value by rounding up
<parameter>value</parameter> if necessary.
The return value of <function>ceil</function> is still of type
<type>float</type> as the value range of <type>float</type> is
usually bigger than that of <type>int</type>.
</simpara>
<simpara>
See also <function>floor</function> and
@ -491,19 +484,16 @@ $x = ceil(4.25);
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>floor</function></funcdef>
<paramdef>float <parameter>number</parameter></paramdef>
<funcdef>float <function>floor</function></funcdef>
<paramdef>float <parameter>value</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<simpara>
Returns the next lowest integer value from
<parameter>number</parameter>. Using <function>floor</function>
on integers is absolutely a waste of time.
</simpara>
<simpara>
NOTE: PHP/FI 2's <function>floor</function> returned a
float. Use: <literal>$new = (double)floor($number);</literal> to
get the old behaviour.
Returns the next lowest integer value by rounding down
<parameter>value</parameter> if neccessary.
The return value of <function>ceil</function> is still of type
<type>float</type> as the value range of <type>float</type> is
usually bigger than that of <type>int</type>.
</simpara>
<simpara>
See also <function>ceil</function> and
@ -1026,12 +1016,12 @@ $foo = round (1.95583, 2); // $foo == 1.96
</programlisting>
</informalexample>
</para>
<note>
<simpara>
The <parameter>precision</parameter> parameter is only
available in PHP 4.
</simpara>
</note>
<note>
<simpara>
The <parameter>precision</parameter> parameter is only
available in PHP 4.
</simpara>
</note>
<simpara>
See also <function>ceil</function> and
<function>floor</function>.

View file

@ -40,6 +40,7 @@
</row>
<row>
<entry>postmaster -i &amp;</entry>
<!-- <entry>pg_connect("", "", "", "", "dbname");</entry> -->
<entry>pg_connect("dbname=MyDbName");</entry>
<entry>OK</entry>
</row>
@ -171,6 +172,27 @@ echo $cmdtuples . " &lt;- cmdtuples affected.";
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>pg_connect</function></funcdef>
<paramdef>string <parameter>host</parameter></paramdef>
<paramdef>string <parameter>port</parameter></paramdef>
<paramdef>string <parameter>dbname</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>pg_connect</function></funcdef>
<paramdef>string <parameter>host</parameter></paramdef>
<paramdef>string <parameter>port</parameter></paramdef>
<paramdef>string <parameter>options</parameter></paramdef>
<paramdef>string <parameter>dbname</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>pg_connect</function></funcdef>
<paramdef>string <parameter>host</parameter></paramdef>
<paramdef>string <parameter>port</parameter></paramdef>
<paramdef>string <parameter>options</parameter></paramdef>
<paramdef>string <parameter>tty</parameter></paramdef>
<paramdef>string <parameter>dbname</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>pg_connect</function></funcdef>
<paramdef>string <parameter>conn_string</parameter></paramdef>

View file

@ -136,6 +136,8 @@ $count++;
<para>
The following example demonstrates how to register a variable, and
how to link correctly to another page using SID.
</para>
<para>
<example>
<title>Counting the number of hits of a single user</title>
<programlisting role="php">
@ -147,17 +149,94 @@ $count++;
Hello visitor, you have seen this page &lt;?php echo $count; ?&gt; times.&lt;p&gt;
&lt;php?
# the &lt;?=SID?&gt; is necessary to preserve the session id
# the &lt;?php echo SID;?&gt; is necessary to preserve the session id
# in the case that the user has disabled cookies
?&gt;
To continue, &lt;A HREF="nextpage.php?&lt;?=SID?&gt;"&gt;click here&lt;/A&gt;
To continue, &lt;A HREF="nextpage.php?&lt;?php echo SID;?&gt;"&gt;click here&lt;/A&gt;
</programlisting>
</example>
</para>
<para>
To implement database storage you need PHP code and a user level
function <function>session_set_save_handler</function>. You would
have to extend the following functions to cover MySQL or another
database.
</para>
<para>
<<<<<<< session.xml
<example>
<title>
Usage of <function>session_set_save_handler</function>
</title>
<programlisting role="php">
&lt;?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++;
?&gt;
</programlisting>
</example>
</para>
<para>
Will produce this results:
</para>
<para>
<programlisting>
$ ./php save_handler.php
Content-Type: text/html
Set-cookie: PHPSESSID=f08b925af0ecb52bdd2de97d95cdbe6b
open (/tmp, PHPSESSID)
read (f08b925af0ecb52bdd2de97d95cdbe6b)
write (f08b925af0ecb52bdd2de97d95cdbe6b, foo|i:2;)
close
</programlisting>
=======
The <literal>&lt;?=SID?&gt;</literal> is not necessary, if
<literal>--enable-trans-sid</literal> was used to compile PHP.
>>>>>>> 1.23
</para>
<para>
<<<<<<< session.xml
The <literal>&lt;?php echo SID;?&gt;</literal> is not necessary, if
<literal>--enable-trans-sid</literal> was used to compile PHP.
</para>
<note>
<para>
@ -167,11 +246,13 @@ To continue, &lt;A HREF="nextpage.php?&lt;?=SID?&gt;"&gt;click here&lt;/A&gt;
</para>
</note>
<para>
=======
To implement database storage, or any other storage method, you
will need to use <function>session_set_save_handler</function> to
create a set of user-level storage functions.
</para>
<para>
>>>>>>> 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.

View file

@ -3426,15 +3426,27 @@ $text = ucfirst ($text); // $text is now Mary had a little lamb
</funcprototype>
</funcsynopsis>
<para>
<<<<<<< strings.xml
<<<<<<< strings.xml
Capitalizes the first character of each word in
<parameter>str</parameter> 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
<parameter>str</parameter> capitalized, if that character is
alphabetic.
>>>>>>> 1.77
<example>
<title><function>ucwords</function> example</title>
<programlisting role="php">
$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.
</programlisting>
</example>
<note>