Fixed bug #51923 (Documentation does not mention changes to return type of shm_attach)

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@304639 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Kalle Sommer Nielsen 2010-10-23 06:30:25 +00:00
parent 09eb46046a
commit 9a06fcaef7

View file

@ -71,6 +71,70 @@
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>5.3.0</entry>
<entry>
This function now returns a resource instead of an
integer.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
As this function used to return an integer value prior to
PHP 5.3.0. To achieve the same value in a portable value the
return value can be cast to an integer like:
</para>
<para>
<example>
<programlisting role="php">
<![CDATA[
<?php
// Create a temporary file and return its path
$tmp = tempnam('/tmp', 'PHP');
// Get the file token key
$key = ftok($tmp, 'a');
// Attach the SHM resource, notice the cast afterwards
$id = shm_attach($key);
if($id === false)
{
die('Unable to create the shared memory segment');
}
// Cast to integer, since prior to PHP 5.3.0 the resource id
// is returned which can be exposed when casting a resource
// to an integer
$id = (integer) $id;
?>
]]>
</programlisting>
</example>
</para>
</note>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>