Added examples for:

* is_binary
* is_buffer
* is_object
* is_unicode


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@267304 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Kalle Sommer Nielsen 2008-10-13 23:35:15 +00:00
parent 964f0c1f63
commit f8c1327682
4 changed files with 150 additions and 4 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<refentry xml:id="function.is-binary" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>is_binary</refname>
@ -40,6 +40,37 @@
<type>binary</type> string, &false; otherwise.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>is_binary</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
// Declare a unicode string
$unicode = 'This is a unicode string';
// Declare a binary string using the 'b' prefix
// available as of PHP 5.2.1, but it will only have
// effect as of PHP 6.0.0
$binary = b'This is a binary string';
var_dump(is_binary($unicode), is_binary($binary));
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(false)
bool(true)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<refentry xml:id="function.is-buffer" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>is_buffer</refname>
@ -42,6 +42,52 @@
&false; otherwise.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>is_buffer</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
// Declare some variables with different types
$types = Array(
'unicode' => 'Unicode string',
'binary' => b'Binary string',
'resource' => fopen('php://stdin', 'r'),
'integer' => 42
);
// Test which types thats a buffer
foreach($types as $type => $value)
{
if(is_buffer($value))
{
echo $type . ' is a either a unicode or binary string';
}
else
{
echo $type . ' is not a buffer value';
}
echo PHP_EOL;
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
unicode is a either a unicode or binary string
binary is a either a unicode or binary string
resource is not a buffer value
integer is not a buffer value
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;

View file

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- $Revision: 1.7 $ -->
<refentry xml:id="function.is-object" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>is_object</refname>
<refpurpose>Finds whether a variable is an object</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
@ -15,6 +16,7 @@
Finds whether the given variable is an object.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
@ -30,6 +32,7 @@
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
@ -37,6 +40,41 @@
&false; otherwise.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>is_object</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
// Declare a simple function to return an
// array from our object
function get_students($obj)
{
if(!is_object($obj))
{
return(false);
}
return($obj->students);
}
// Declare a new class instance and fill up
// some values
$obj = new stdClass;
$obj->students = Array('Kalle', 'Ross', 'Felipe');
var_dump(get_students(NULL));
var_dump(get_students($obj));
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
@ -47,6 +85,7 @@
</para>
</note>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
@ -59,6 +98,7 @@
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<refentry xml:id="function.is-unicode" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>is_unicode</refname>
@ -40,6 +40,35 @@
string, &false; otherwise.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>is_unicode</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
// Declare a unicode string
$unicode = 'This is a unicode string';
// Declare a binary string
$binary = b'This is a binary string';
var_dump(is_unicode($unicode), is_bunicode($binary));
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(true)
bool(false)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;