mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 08:28:54 +00:00
Remove migration guides for PHP 5
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de> Closes GH-157.
This commit is contained in:
parent
a2afb71b63
commit
027f187b3e
15 changed files with 4 additions and 9824 deletions
|
@ -6,9 +6,8 @@
|
|||
<sect1 xml:id="debugger-about">
|
||||
<title>About debugging in PHP</title>
|
||||
<simpara>
|
||||
PHP 5.6 is shipped with the <link linkend="migration56.new-features.phpdbg">phpdbg interactive debugger</link>.
|
||||
PHP versions below 5.6 do not have an internal debugging facility though.
|
||||
You can use one of the external debuggers though. The
|
||||
PHP is shipped with the <link linkend="migration56.new-features.phpdbg">phpdbg</link> interactive debugger.
|
||||
External debuggers can also be used. The
|
||||
<link xlink:href="&url.zend.ide;">Zend IDE</link> includes
|
||||
a debugger, and there are also some free debugger extensions
|
||||
like DBG at <link xlink:href="&url.dbg;">&url.dbg;</link>, the
|
||||
|
|
|
@ -135,12 +135,6 @@
|
|||
<entry>PHP_INI_ALL with restrictions</entry>
|
||||
<entry>Available since PHP 7.0.0.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><link linkend="ini.zend.ze1-compatibility-mode">zend.ze1_compatibility_mode</link></entry>
|
||||
<entry>"0"</entry>
|
||||
<entry>PHP_INI_ALL</entry>
|
||||
<entry>Removed in PHP 5.3.0</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>detect_unicode</entry>
|
||||
<entry>"1"</entry>
|
||||
|
@ -416,32 +410,7 @@
|
|||
</note>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry xml:id="ini.zend.ze1-compatibility-mode">
|
||||
<term>
|
||||
<parameter>zend.ze1_compatibility_mode</parameter>
|
||||
<type>bool</type>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Enable compatibility mode with Zend Engine 1 (PHP 4). It affects
|
||||
the cloning, casting (objects with no properties cast to &false; or 0), and <link
|
||||
linkend="language.oop5.object-comparison">comparing of objects</link>.
|
||||
In this mode, objects are passed by value instead of reference by
|
||||
default.
|
||||
</para>
|
||||
<para>
|
||||
See also the section titled
|
||||
<link linkend="migration5">Migrating from PHP 4 to PHP 5</link>.
|
||||
</para>
|
||||
<warning>
|
||||
<simpara>This feature has been <emphasis>DEPRECATED</emphasis> and <emphasis>REMOVED</emphasis>
|
||||
as of PHP 5.3.0.
|
||||
</simpara>
|
||||
</warning>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry xml:id="ini.hard-timeout">
|
||||
<term>
|
||||
<parameter>hard_timeout</parameter>
|
||||
|
|
|
@ -2530,12 +2530,6 @@
|
|||
<entry>PHP_INI_SYSTEM</entry>
|
||||
<entry>Available since PHP 5.4.0</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><link linkend="ini.zend.ze1-compatibility-mode">zend.ze1_compatibility_mode</link></entry>
|
||||
<entry>"0"</entry>
|
||||
<entry>PHP_INI_ALL</entry>
|
||||
<entry>Available since PHP 5.0.0. Removed in PHP 5.3.0.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><link linkend="ini.zend-extension">zend_extension</link></entry>
|
||||
<entry>NULL</entry>
|
||||
|
|
|
@ -1,977 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<appendix xml:id="migration5" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>Migrating from PHP 4 to PHP 5.0.x</title>
|
||||
<para>
|
||||
&manual.migration.seealso;
|
||||
<link linkend="migration51">5.1.x</link>,
|
||||
<link linkend="migration52">5.2.x</link>,
|
||||
<link linkend="migration53">5.3.x</link>,
|
||||
<link linkend="migration54">5.4.x</link>,
|
||||
<link linkend="migration55">5.5.x</link> and
|
||||
<link linkend="migration56">5.6.x</link>.
|
||||
</para>
|
||||
|
||||
<section xml:id="migration5.changes">
|
||||
<title>What has changed in PHP 5.0.x</title>
|
||||
<para>
|
||||
PHP 5 and the integrated Zend Engine 2 have greatly improved PHP's
|
||||
performance and capabilities, but great care has been taken to break as
|
||||
little existing code as possible. So migrating your code from PHP 4 to 5
|
||||
should be very easy. Most existing PHP 4 code should be ready to run
|
||||
without changes, but you should still know about the <link
|
||||
linkend="migration5.incompatible">few differences</link> and
|
||||
take care to test your code before switching versions in production
|
||||
environments.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration5.incompatible">
|
||||
<title>Backward Incompatible Changes</title>
|
||||
<para>
|
||||
Although most existing PHP 4 code should work without changes, you should
|
||||
pay attention to the following backward incompatible changes:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
There are some <link linkend="reserved.keywords">new reserved
|
||||
keywords</link>.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>strrpos</function> and <function>strripos</function> now use
|
||||
the entire string as a needle.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
Illegal use of string offsets causes <constant>E_ERROR</constant> instead
|
||||
of <constant>E_WARNING</constant>. An example illegal use is:
|
||||
<literal>$str = 'abc'; unset($str[0]);</literal>.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>array_merge</function> was changed to accept only arrays. If a
|
||||
non-array variable is passed, a <constant>E_WARNING</constant> will be
|
||||
thrown for every such parameter. Be careful because your code may start
|
||||
emitting <constant>E_WARNING</constant> out of the blue.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<constant>PATH_TRANSLATED</constant> server variable is no longer set implicitly under
|
||||
Apache2 SAPI in contrast to the situation in PHP 4, where it is set to
|
||||
the same value as the <constant>SCRIPT_FILENAME</constant> server variable when it is not
|
||||
populated by Apache. This change was made to comply with the <link
|
||||
xlink:href="&url.rfc;3875">CGI/1.1 specification</link>. Please refer to <link
|
||||
xlink:href="&url.php.bugs;23610">bug #23610</link> for further information,
|
||||
and see also the <varname>$_SERVER['PATH_TRANSLATED']</varname>
|
||||
description in the manual. This issue
|
||||
also affects PHP versions >= 4.3.2.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
The <constant>T_ML_COMMENT</constant> constant is no longer defined by
|
||||
the <link linkend="ref.tokenizer">Tokenizer</link> extension. If
|
||||
error_reporting is set to <constant>E_ALL</constant>, PHP will
|
||||
generate a notice. Although the <constant>T_ML_COMMENT</constant> was
|
||||
never used at all, it was defined in PHP 4. In both PHP 4 and PHP 5
|
||||
// and /* */ are resolved as the <constant>T_COMMENT</constant>
|
||||
constant. However the PHPDoc style comments <literal>/** */</literal>, which starting PHP
|
||||
5 are parsed by PHP, are recognized as <constant>T_DOC_COMMENT</constant>.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<varname>$_SERVER</varname> should be populated with <varname>argc</varname> and
|
||||
<varname>argv</varname> if
|
||||
<link linkend="ini.variables-order">variables_order</link> includes "S".
|
||||
If you have specifically configured your system to not create
|
||||
<varname>$_SERVER</varname>, then of course it shouldn't be there.
|
||||
The change was to always make <varname>argc</varname>
|
||||
and <varname>argv</varname> available in the CLI version regardless of the
|
||||
<link linkend="ini.variables-order">variables_order</link> setting.
|
||||
As in, the CLI version will now always populate the global
|
||||
<varname>$argc</varname> and <varname>$argv</varname> variables.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
An object with no properties is no longer considered "empty".
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
In some cases classes must be declared before use. It only happens if
|
||||
some of the new features of PHP 5 (such as <link
|
||||
linkend="language.oop5.interfaces">interfaces</link>) are used.
|
||||
Otherwise the behaviour is the old.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>get_class</function>, <function>get_parent_class</function>
|
||||
and <function>get_class_methods</function> now return the name of the
|
||||
classes/methods as they were declared (case-sensitive) which may lead to
|
||||
problems in older scripts that rely on the previous behaviour (the
|
||||
class/method name was always returned lowercased). A possible solution
|
||||
is to search for those functions in all your scripts and use
|
||||
<function>strtolower</function>.
|
||||
</simpara>
|
||||
<simpara>
|
||||
This case sensitivity change also applies to the
|
||||
<link linkend="language.constants.predefined">magical predefined
|
||||
constants</link> <constant>__CLASS__</constant>,
|
||||
<constant>__METHOD__</constant>, and <constant>__FUNCTION__</constant>.
|
||||
The values are returned exactly as they're declared (case-sensitive).
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ip2long</function> now returns &false; when an invalid IP
|
||||
address is passed as argument to the function, and no longer
|
||||
<literal>-1</literal>.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
If there are functions defined in the included file, they can be used in the
|
||||
main file independent if they are before <function>return</function> or after.
|
||||
If the file is included twice, PHP 5 issues fatal error because functions
|
||||
were already declared, while PHP 4 doesn't complain about it.
|
||||
It is recommended to use <function>include_once</function> instead of
|
||||
checking if the file was already included and conditionally return inside
|
||||
the included file.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>include_once</function> and <function>require_once</function>
|
||||
first normalize the path of included file on Windows so that including
|
||||
A.php and a.php include the file just once.
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
Passing an array to a function by value no longer resets the
|
||||
array's internal pointer for array accesses made within the
|
||||
function. In other words, in PHP 4 when you passed an array to a
|
||||
function, its internal pointer inside the function would be
|
||||
reset, while in PHP 5, when you pass an array to a function, its
|
||||
array pointer within the function will be wherever it was when
|
||||
the array was passed to the function.
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
<example>
|
||||
<title><function>strrpos</function> and <function>strripos</function> now
|
||||
use the entire string as a needle</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
var_dump(strrpos('ABCDEF','DEF')); //int(3)
|
||||
|
||||
var_dump(strrpos('ABCDEF','DAF')); //bool(false)
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>An object with no properties is no longer considered "empty"</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class test { }
|
||||
$t = new test();
|
||||
|
||||
var_dump(empty($t)); // echo bool(false)
|
||||
|
||||
if ($t) {
|
||||
// Will be executed
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>In some cases classes must be declared before used</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
//works with no errors:
|
||||
$a = new a();
|
||||
class a {
|
||||
}
|
||||
|
||||
|
||||
//throws an error:
|
||||
$a = new b();
|
||||
|
||||
interface c{
|
||||
}
|
||||
class b implements c {
|
||||
}
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration5.cli-cgi">
|
||||
<title>CLI and CGI</title>
|
||||
<para>
|
||||
In PHP 5 there were some changes in CLI and CGI filenames. In PHP 5, the
|
||||
CGI version was renamed to <filename>php-cgi.exe</filename> (previously
|
||||
<filename>php.exe</filename>) and the CLI version now sits in the main
|
||||
directory (previously <filename>cli/php.exe</filename>).
|
||||
</para>
|
||||
<para>
|
||||
In PHP 5 it was also introduced a new mode:
|
||||
<filename>php-win.exe</filename>. This is equal to the CLI version, except
|
||||
that php-win doesn't output anything and thus provides no console (no "dos
|
||||
box" appears on the screen). This behavior is similar to php-gtk.
|
||||
</para>
|
||||
<para>
|
||||
In PHP 5, the CLI version will always populate the global
|
||||
<varname>$argv</varname> and <varname>$argc</varname> variables regardless
|
||||
of any &php.ini; directive setting. Even having
|
||||
<link linkend="ini.register-argc-argv">register_argc_argv</link> set to
|
||||
<literal>off</literal> will have no affect in CLI.
|
||||
</para>
|
||||
<para>
|
||||
See also the <link linkend="features.commandline">command line
|
||||
reference</link>.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration5.configuration">
|
||||
<title>Migrating Configuration Files</title>
|
||||
<para>
|
||||
Since the ISAPI modules changed their names, from php4xxx to php5xxx, you
|
||||
need to make some changes in the configuration files. There were also
|
||||
changes in the CLI and CGI filenames. Please refer to the <link
|
||||
linkend="migration5.cli-cgi">corresponding section</link> for more
|
||||
information.
|
||||
</para>
|
||||
<para>
|
||||
Migrating the Apache configuration is extremely easy. See the example below
|
||||
to check the change you need to do:
|
||||
<example>
|
||||
<title>Migrating Apache configuration files for PHP 5</title>
|
||||
<programlisting role="apache-conf">
|
||||
<![CDATA[
|
||||
# change this line:
|
||||
LoadModule php4_module /php/sapi/php4apache2.dll
|
||||
|
||||
# with this one:
|
||||
LoadModule php5_module /php/php5apache2.dll
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
If your web server is running PHP in CGI mode, you should note that the
|
||||
CGI version has changed its name from <filename>php.exe</filename> to
|
||||
<filename>php-cgi.exe</filename>.
|
||||
In Apache, you should do something like this:
|
||||
<example>
|
||||
<title>Migrating Apache configuration files for PHP 5, CGI mode</title>
|
||||
<programlisting role="apache-conf">
|
||||
<![CDATA[
|
||||
# change this line:
|
||||
Action application/x-httpd-php "/php/php.exe"
|
||||
|
||||
# with this one:
|
||||
Action application/x-httpd-php "/php/php-cgi.exe"
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
In other web servers you need to change either the CGI or the ISAPI module
|
||||
filenames.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration5.functions">
|
||||
<title>New Functions</title>
|
||||
<para>
|
||||
In PHP 5 there are some new functions. Here is the list of them:
|
||||
</para>
|
||||
<para><link linkend="ref.array">Arrays</link>:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>array_combine</function> - Creates an array by using one array
|
||||
for keys and another for its values
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>array_diff_uassoc</function> - Computes the difference of
|
||||
arrays with additional index check which is performed by a user supplied
|
||||
callback function
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>array_udiff</function> - Computes the difference of arrays by
|
||||
using a callback function for data comparison
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>array_udiff_assoc</function> - Computes the difference of
|
||||
arrays with additional index check. The data is compared by using a
|
||||
callback function
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>array_udiff_uassoc</function> - Computes the difference of
|
||||
arrays with additional index check. The data is compared by using a
|
||||
callback function. The index check is done by a callback function also
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>array_walk_recursive</function> - Apply a user function
|
||||
recursively to every member of an array
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>array_uintersect_assoc</function> - Computes the intersection of
|
||||
arrays with additional index check. The data is compared by using a
|
||||
callback function
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>array_uintersect_uassoc</function> - Computes the intersection of
|
||||
arrays with additional index check. Both the data and the indexes are compared
|
||||
by using separate callback functions
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>array_uintersect</function> - Computes the intersection of arrays.
|
||||
The data is compared by using a callback function
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para><link linkend="ref.ibase">InterBase</link>:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_affected_rows</function> - Return the number of rows
|
||||
that were affected by the previous query
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_backup</function> - Initiates a backup task in the
|
||||
service manager and returns immediately
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_commit_ret</function> - Commit a transaction without
|
||||
closing it
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_db_info</function> - Request statistics about a
|
||||
database
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_drop_db</function> - Drops a database
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_errcode</function> - Return an error code
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_free_event_handler</function> - Cancels a registered
|
||||
event handler
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_gen_id</function> - Increments the named generator and
|
||||
returns its new value
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_maintain_db</function> - Execute a maintenance command
|
||||
on the database server
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_name_result</function> - Assigns a name to a result set
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_num_params</function> - Return the number of parameters
|
||||
in a prepared query
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_param_info</function> - Return information about a
|
||||
parameter in a prepared query
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_restore</function> - Initiates a restore task in the
|
||||
service manager and returns immediately
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_rollback_ret</function> - Rollback transaction and
|
||||
retain the transaction context
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_server_info</function> - Request statistics about a
|
||||
database server
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_service_attach</function> - Connect to the service manager
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_service_detach</function> - Disconnect from the
|
||||
service manager
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_set_event_handler</function> - Register a callback
|
||||
function to be called when events are posted
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ibase_wait_event</function> - Wait for an event to be posted
|
||||
by the database
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para><link linkend="ref.iconv">iconv</link>:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>iconv_mime_decode</function> - Decodes a MIME header field
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>iconv_mime_decode_headers</function> - Decodes multiple MIME
|
||||
header fields at once
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>iconv_mime_encode</function> - Composes a MIME header field
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>iconv_strlen</function> - Returns the character count of
|
||||
string
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>iconv_strpos</function> - Finds position of first occurrence
|
||||
of a needle within a haystack
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>iconv_strrpos</function> - Finds the last occurrence of a
|
||||
needle within a haystack
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>iconv_substr</function> - Cut out part of a string
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para><link linkend="ref.stream">Streams</link>:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>stream_copy_to_stream</function> - Copies data from one stream
|
||||
to another
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>stream_get_line</function> - Gets line from stream resource up
|
||||
to a given delimiter
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>stream_socket_accept</function> - Accept a connection on a
|
||||
socket created by <function>stream_socket_server</function>
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>stream_socket_client</function> - Open Internet or Unix domain
|
||||
socket connection
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>stream_socket_get_name</function> - Retrieve the name of the
|
||||
local or remote sockets
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>stream_socket_recvfrom</function> - Receives data from a
|
||||
socket, connected or not
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>stream_socket_sendto</function> - Sends a message to a socket,
|
||||
whether it is connected or not
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>stream_socket_server</function> - Create an Internet or Unix
|
||||
domain server socket
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para><link linkend="ref.datetime">Date and time related</link>:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>idate</function> - Format a local time/date as integer
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>date_sunset</function> - Time of sunset for a given day and
|
||||
location
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>date_sunrise</function> - Time of sunrise for a given day and
|
||||
location
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>time_nanosleep</function> - Delay for a number of seconds and
|
||||
nanoseconds
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para><link linkend="ref.strings">Strings</link>:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>str_split</function> - Convert a string to an array
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>strpbrk</function> - Search a string for any of a set of
|
||||
characters
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>substr_compare</function> - Binary safe optionally case
|
||||
insensitive comparison of two strings from an offset, up to length
|
||||
characters
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>Other:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>convert_uudecode</function> - decode a uuencoded string
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>convert_uuencode</function> - uuencode a string
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>curl_copy_handle</function> - Copy a cURL handle
|
||||
along with all of its preferences
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>dba_key_split</function> - Splits a key in string
|
||||
representation into array representation
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>dbase_get_header_info</function> - Get the header info of a
|
||||
dBase database
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>dbx_fetch_row</function> - Fetches rows from a query-result
|
||||
that had the <constant>DBX_RESULT_UNBUFFERED</constant> flag set
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>fbsql_set_password</function> - Change the password for a
|
||||
given user
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>file_put_contents</function> - Write a string to a file
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ftp_alloc</function> - Allocates space for a file to be
|
||||
uploaded
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>get_declared_interfaces</function> - Returns an array of all
|
||||
declared interfaces
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>get_headers</function> - Fetches all the headers sent by the
|
||||
server in response to a HTTP request
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>headers_list</function> - Returns a list of response headers
|
||||
sent (or ready to send)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>http_build_query</function> - Generate URL-encoded query string
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>image_type_to_extension</function> - Get file extension for
|
||||
image-type returned by <function>getimagesize</function>,
|
||||
<function>exif_read_data</function>,
|
||||
<function>exif_thumbnail</function>,
|
||||
<function>exif_imagetype</function>
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>imagefilter</function> - Applies a filter to an image using
|
||||
custom arguments
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>imap_getacl</function> - Gets the ACL for a given mailbox
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>ldap_sasl_bind</function> - Bind to LDAP directory using SASL
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>mb_list_encodings</function> - Returns an array of all
|
||||
supported encodings
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>pcntl_getpriority</function> - Get the priority of any
|
||||
process
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>pcntl_wait</function> - Waits on or returns the status of a
|
||||
forked child as defined by the <literal>waitpid()</literal> system call
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>pg_version</function> - Returns an array with client, protocol
|
||||
and server version (when available)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>php_check_syntax</function> - Check the syntax of the
|
||||
specified file
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>php_strip_whitespace</function> - Return source with stripped
|
||||
comments and whitespace
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>proc_nice</function> - Change the priority of the current
|
||||
process
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>pspell_config_data_dir</function> - Change location of
|
||||
language data files
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>pspell_config_dict_dir</function> - Change location of the
|
||||
main word list
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>setrawcookie</function> - Send a cookie without URL-encoding
|
||||
the value
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>scandir</function> - List files and directories inside the
|
||||
specified path
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>snmp_read_mib</function> - Reads and parses a MIB file into
|
||||
the active MIB tree
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<function>sqlite_fetch_column_types</function> - Return an array of
|
||||
column types from a particular table
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<note>
|
||||
<para>
|
||||
The <link linkend="ref.tidy">Tidy</link> extension has also changed its
|
||||
API completely.
|
||||
</para>
|
||||
</note>
|
||||
</section>
|
||||
|
||||
|
||||
<section xml:id="migration5.newconf">
|
||||
<title>New Directives</title>
|
||||
<para>
|
||||
There were some new &php.ini; directives introduced in PHP 5. Here is a
|
||||
list of them:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<link linkend="ini.mail.force_extra_parameters">mail.force_extra_parameters</link> -
|
||||
Force the addition of the specified
|
||||
parameters to be passed as extra parameters to the sendmail binary.
|
||||
These parameters will always replace the value of the 5th parameter to
|
||||
<function>mail</function>, even in safe mode
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<link linkend="ini.register-long-arrays">register_long_arrays</link> -
|
||||
allow/disallow PHP to register the deprecated long <varname>$HTTP_*_VARS</varname>
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<link linkend="ini.session.hash-function">session.hash_function</link> -
|
||||
select a hash function (MD5 or SHA-1)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<link
|
||||
linkend="ini.session.hash-bits-per-character">session.hash_bits_per_character</link>
|
||||
- define how many bits are stored in each character when converting the
|
||||
binary hash data to something readable (from 4 to 6)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<link linkend="ini.zend.ze1-compatibility-mode">zend.ze1_compatibility_mode</link>
|
||||
- Enable compatibility mode with Zend Engine 1 (PHP 4)
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration5.databases">
|
||||
<title>Databases</title>
|
||||
<para>
|
||||
There were some changes in PHP 5 regarding databases (MySQL and SQLite).
|
||||
</para>
|
||||
<para>
|
||||
In PHP 5 the MySQL client libraries are not bundled, because of license
|
||||
and maintenance problems. MySQL is supported with the only
|
||||
change being that MySQL support is no longer enabled by
|
||||
<emphasis>default</emphasis> in PHP 5. This essentially means that
|
||||
PHP doesn't include the <option role="configure">--with-mysql</option>
|
||||
option in the <link linkend="configuration">configure</link> line so
|
||||
that you must now manually do this when compiling PHP. Windows users will
|
||||
need to edit &php.ini; and enable the <filename>php_mysql.dll</filename>
|
||||
DLL as in PHP 4 no such DLL existed, it was simply built into your Windows
|
||||
PHP binaries.
|
||||
</para>
|
||||
<para>
|
||||
There is also a new extension, <link linkend="ref.mysqli">MySQLi (Improved
|
||||
MySQL)</link>, which is designed to work with MySQL 4.1 and above.
|
||||
</para>
|
||||
<para>
|
||||
Since PHP 5, the SQLite extension is
|
||||
built-in PHP. SQLite is an embeddable SQL database engine and is not a
|
||||
client library used to connect to a big database server (like MySQL or
|
||||
PostgreSQL). The SQLite library reads and writes directly to and from the
|
||||
database files on disk.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
|
||||
<section xml:id="migration5.oop">
|
||||
<title>New Object Model</title>
|
||||
<para>
|
||||
In PHP 5 there is a new Object Model. PHP's handling of objects has been
|
||||
completely rewritten, allowing for better performance and more features.
|
||||
In previous versions of PHP, objects were handled like primitive types
|
||||
(for instance integers and strings). The drawback of this method was that
|
||||
semantically the whole object was copied when a variable was assigned, or
|
||||
passed as a parameter to a method. In the new approach, objects are
|
||||
referenced by handle, and not by value (one can think of a handle as an
|
||||
object's identifier).
|
||||
</para>
|
||||
<para>
|
||||
Many PHP programmers aren't even aware of the copying quirks of the old
|
||||
object model and, therefore, the majority of PHP applications will work
|
||||
out of the box, or with very few modifications.
|
||||
</para>
|
||||
<para>
|
||||
The new Object Model is documented at the <link
|
||||
linkend="language.oop5">Language Reference</link>.
|
||||
</para>
|
||||
<para>
|
||||
In PHP 5, function with the name of a class is called as a constructor
|
||||
only if defined in the same class. In PHP 4, it is called also if defined
|
||||
in the parent class.
|
||||
</para>
|
||||
<para>
|
||||
See also the <link linkend="ini.zend.ze1-compatibility-mode">
|
||||
zend.ze1_compatibility_mode</link> directive for compatibility with
|
||||
PHP 4.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migrating5.errorrep">
|
||||
<title>Error Reporting</title>
|
||||
<para>
|
||||
As of PHP 5 the error reporting
|
||||
constant <constant>E_STRICT</constant> is available, with the
|
||||
value <literal>2048</literal>. When enabled, messages will be
|
||||
issued to warn you about code usage which is deprecated or which
|
||||
may not be future-proof.
|
||||
</para>
|
||||
<note>
|
||||
<simpara>
|
||||
<constant>E_ALL</constant> does not include <constant>E_STRICT</constant>,
|
||||
so it's not enabled by default. You must explicitly set the error
|
||||
reporting level to include <constant>E_STRICT</constant> in order
|
||||
to see these messages.
|
||||
</simpara>
|
||||
</note>
|
||||
<para>
|
||||
See <link linkend="errorfunc.constants">Predefined Constants</link> for more information.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
</appendix>
|
||||
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
|
@ -1,900 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<appendix xml:id="migration51" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>Migrating from PHP 5.0.x to PHP 5.1.x</title>
|
||||
<para>
|
||||
&manual.migration.seealso;
|
||||
<link linkend="migration5">5.0.x</link>,
|
||||
<link linkend="migration52">5.2.x</link>,
|
||||
<link linkend="migration53">5.3.x</link>,
|
||||
<link linkend="migration54">5.4.x</link>,
|
||||
<link linkend="migration55">5.5.x</link> and
|
||||
<link linkend="migration56">5.6.x</link>.
|
||||
</para>
|
||||
|
||||
<section xml:id="migration51.changes">
|
||||
<title>Key PHP 5.1.x features</title>
|
||||
<para>
|
||||
Some of the key features of PHP 5.1.x include:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
A complete rewrite of date handling code, with improved timezone support.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Significant performance improvements compared to PHP 5.0.X.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
PDO extension is now enabled by default.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Over 30 new functions in various extensions and built-in functionality.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Over 400 various bug fixes.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.references">
|
||||
<title>Changes in reference handling</title>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.references-overview">Overview</link>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.references-fails">Code that worked under PHP
|
||||
4.3.x, but now fails</link>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.references-error">Code that worked under PHP
|
||||
4.3.x, but now throws an error</link>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.references-works">Code that failed under PHP
|
||||
4.3.x, but now works</link>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.references-didnotwork">Code that
|
||||
should have worked under PHP 5.0.x</link>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.references-warnings">Warnings that came and
|
||||
went</link>
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<section xml:id="migration51.references-overview">
|
||||
<title>Overview</title>
|
||||
<para>
|
||||
From the PHP script writer's point of view, the change most likely to
|
||||
impact legacy code is in the way that references are handled in all PHP
|
||||
versions post-dating the PHP 4.4.0 release.
|
||||
</para>
|
||||
<para>
|
||||
Until and including PHP 4.3, it was possible to send, assign or return
|
||||
variables by reference that should really be returned by value, such as
|
||||
a constant, a temporary value (e.g. the result of an expression), or the
|
||||
result of a function that had itself been returned by value, as here:
|
||||
</para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$foo = "123";
|
||||
|
||||
function return_value() {
|
||||
global $foo;
|
||||
return $foo;
|
||||
}
|
||||
|
||||
$bar = &return_value();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
<para>
|
||||
Although this code would usually work as expected under PHP 4.3, in the
|
||||
general case the result is undefined. The Zend Engine could not act
|
||||
correctly on these values as references. This bug could and did lead to
|
||||
various hard-to-reproduce memory corruption problems, particularly
|
||||
where the code base was large.
|
||||
</para>
|
||||
<para>
|
||||
In PHP 4.4.0, PHP 5.0.4 and all subsequent PHP releases, the Engine was
|
||||
fixed to 'know' when the reference operation is being used on a value
|
||||
that should not be referenced. The actual value is now used in such
|
||||
cases, and a warning is emitted. The warning takes the form of an
|
||||
<constant>E_NOTICE</constant> in PHP 4.4.0 and up, and
|
||||
<constant>E_STRICT</constant> in PHP 5.0.4 and up.
|
||||
</para>
|
||||
<para>
|
||||
Code that could potentially produce memory corruption can no longer do
|
||||
so. However, some legacy code might work differently as a result.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.references-fails">
|
||||
<title>Code that worked under PHP 4.3, but now fails</title>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function func(&$arraykey) {
|
||||
return $arraykey; // function returns by value!
|
||||
}
|
||||
|
||||
$array = array('a', 'b', 'c');
|
||||
foreach (array_keys($array) as $key) {
|
||||
$y = &func($array[$key]);
|
||||
$z[] =& $y;
|
||||
}
|
||||
|
||||
var_dump($z);
|
||||
?>
|
||||
<]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Running the above script under any version of PHP that pre-dates the
|
||||
reference fix would produce this output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
array(3) {
|
||||
[0]=>
|
||||
&string(1) "a"
|
||||
[1]=>
|
||||
&string(1) "b"
|
||||
[2]=>
|
||||
&string(1) "c"
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
<para>
|
||||
Following the reference fix, the same code would result in:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
array(3) {
|
||||
[0]=>
|
||||
&string(1) "c"
|
||||
[1]=>
|
||||
&string(1) "c"
|
||||
[2]=>
|
||||
&string(1) "c"
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
</informalexample>
|
||||
<para>
|
||||
This is because, following the changes, <literal>func()</literal>
|
||||
assigns by value. The value of <varname>$y</varname> is re-assigned,
|
||||
and reference-binding is preserved from <varname>$z</varname>. Prior to
|
||||
the fix, the value was assigned by reference, leading <varname>$y</varname>
|
||||
to be re-bound on each assignment. The attempt to bind to a temporary
|
||||
value by reference was the cause of the memory corruption.
|
||||
</para>
|
||||
<para>
|
||||
Such code can be made to work identically in both the pre-fix and the
|
||||
post-fix PHP versions. The signature of <literal>func()</literal> can
|
||||
be altered to return by reference, or the reference assignment can be
|
||||
removed from the result of <literal>func()</literal>.
|
||||
</para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function func() {
|
||||
return 'function return';
|
||||
}
|
||||
|
||||
$x = 'original value';
|
||||
$y =& $x;
|
||||
$y = &func();
|
||||
echo $x;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
<para>
|
||||
In PHP 4.3 <varname>$x</varname> would be 'original value', whereas after
|
||||
the changes it would be 'function return' - remember that where the
|
||||
function does not return by reference, the reference assignment is
|
||||
converted to a regular assignment. Again, this can be brought to a common
|
||||
base, either by forcing <literal>func()</literal> to return by reference
|
||||
or by eliminating the by-reference assignment.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.references-error">
|
||||
<title>Code that worked under PHP 4.3.x, but now throws an error</title>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class Foo {
|
||||
|
||||
function getThis() {
|
||||
return $this;
|
||||
}
|
||||
|
||||
function destroyThis() {
|
||||
$baz =& $this->getThis();
|
||||
}
|
||||
}
|
||||
|
||||
$bar = new Foo();
|
||||
$bar->destroyThis();
|
||||
var_dump($bar);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
<para>
|
||||
In PHP 5.0.3, <varname>$bar</varname> evaluated to <constant>NULL</constant>
|
||||
instead of returning an object. That happened because
|
||||
<literal>getThis()</literal> returns by value, but the value here is
|
||||
assigned by reference. Although it now works in the expected way, this is
|
||||
actually invalid code which will throw an <constant>E_NOTICE</constant>
|
||||
under PHP 4.4 or an <constant>E_STRICT</constant> under PHP 5.0.4 and up.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.references-works">
|
||||
<title>Code that failed under PHP 4.3.x, but now works</title>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function &f() {
|
||||
$x = "foo";
|
||||
var_dump($x);
|
||||
print "$x\n";
|
||||
return($a);
|
||||
}
|
||||
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$h = &f();
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
In PHP 4.3 the third call to <function>var_dump</function> produces
|
||||
<constant>NULL</constant>, due to the memory corruption caused by
|
||||
returning an uninitialized value by reference. This is valid code
|
||||
in PHP 5.0.4 and up, but threw errors in earlier releases of PHP.
|
||||
</para>
|
||||
</informalexample>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$arr = array('a1' => array('alfa' => 'ok'));
|
||||
$arr =& $arr['a1'];
|
||||
echo '-'.$arr['alfa']."-\n";
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Until PHP 5.0.5, it wasn't possible to assign an array element by
|
||||
reference in this way. It now is.
|
||||
</para>
|
||||
</informalexample>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.references-didnotwork">
|
||||
<title>Code that <literal>should have worked</literal> under PHP 5.0.x</title>
|
||||
<para>
|
||||
There are a couple of instances of bugs reported under PHP 5.0 prior to
|
||||
the reference fixes which now 'work'. However, in both cases errors are
|
||||
thrown by PHP 5.1.x, because the code was invalid in the first place.
|
||||
Returning values by reference using <literal>self::</literal> now works
|
||||
in the general case but throws an <constant>E_STRICT</constant> warning,
|
||||
and although your mileage may vary when assigning by reference to an
|
||||
overloaded object, you will still see an <constant>E_ERROR</constant>
|
||||
when you try it, even where the assignment itself appears to work.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.references-warnings">
|
||||
<title>Warnings that came and went</title>
|
||||
<para>
|
||||
Nested calls to functions returning by reference are valid code under both
|
||||
PHP 4.3.x and PHP 5.1.x, but threw an unwarranted
|
||||
<constant>E_NOTICE</constant> or <constant>E_STRICT</constant> under the
|
||||
intervening PHP releases.
|
||||
</para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function & foo() {
|
||||
$var = 'ok';
|
||||
return $var;
|
||||
}
|
||||
|
||||
function & bar() {
|
||||
return foo();
|
||||
}
|
||||
|
||||
$a =& bar();
|
||||
echo "$a\n";
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</section>
|
||||
</section>
|
||||
<section xml:id="migration51.reading">
|
||||
<title>Reading []</title>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class XmlTest {
|
||||
|
||||
function test_ref(&$test) {
|
||||
$test = "ok";
|
||||
}
|
||||
|
||||
function test($test) { }
|
||||
|
||||
function run() {
|
||||
$ar = array();
|
||||
$this->test_ref($ar[]);
|
||||
var_dump($ar);
|
||||
$this->test($ar[]);
|
||||
}
|
||||
}
|
||||
|
||||
$o = new XmlTest();
|
||||
$o->run();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
<para>
|
||||
This should always have thrown a fatal <constant>E_ERROR</constant>,
|
||||
because [] cannot be used for reading in PHP. It is invalid code in
|
||||
PHP 4.4.2 and PHP 5.0.5 upward.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.integer-parameters">
|
||||
<title>Integer values in function parameters</title>
|
||||
<para>
|
||||
With the advent of PHP 5.0.x, a new parameter parsing API was introduced
|
||||
which is used by a large number of PHP functions. In all versions of PHP
|
||||
between 5.0.x and 5.1.x, the handling of integer values was very strict and
|
||||
would reject non-well formed numeric values when a PHP function expected an
|
||||
integer. These checks have now been relaxed to support non-well formed
|
||||
numeric strings such as " 123" and "123 ", and will no longer fail as they
|
||||
did under PHP 5.0.x. However, to promote code safety and input validation,
|
||||
PHP functions will now emit an <constant>E_NOTICE</constant> when such
|
||||
strings are passed as integers.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.oop">
|
||||
<title>Class and object changes</title>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.oop-functions"><literal>instanceof</literal>,
|
||||
<literal>is_a()</literal>, <literal>is_subclass_of()</literal> and
|
||||
<literal>catch</literal></link>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.oop-methods">Abstract private methods</link>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.oop-modifiers">Access modifiers in
|
||||
interfaces</link>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.oop-inheritance">Changes in inheritance
|
||||
rules</link>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.oop-constants">Class constants</link>
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<section xml:id="migration51.oop-functions">
|
||||
<title><literal>instanceof</literal>, <literal>is_a()</literal>,
|
||||
<literal>is_subclass_of()</literal> and <literal>catch</literal></title>
|
||||
<para>
|
||||
In PHP 5.0, <literal>is_a()</literal> was deprecated and replaced by the
|
||||
<literal>instanceof</literal> operator. There were some issues with the
|
||||
initial implementation of <literal>instanceof</literal>, which relied on
|
||||
<literal>__autoload()</literal> to search for missing classes.
|
||||
If the class was not present, <literal>instanceof</literal> would throw
|
||||
a fatal <constant>E_ERROR</constant> due to the failure of
|
||||
<literal>__autoload()</literal> to discover that class. The same behaviour
|
||||
occurred in the <literal>catch</literal> operator and the
|
||||
<literal>is_subclass_of()</literal> function, for the same reason.
|
||||
</para>
|
||||
<para>
|
||||
None of these functions or operators call <literal>__autoload()</literal>
|
||||
in PHP 5.1.x, and the <literal>class_exists()</literal> workarounds used
|
||||
in code written for PHP 5.0.x, while not problematic in any way, are no
|
||||
longer necessary.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.oop-methods">
|
||||
<title>Abstract private methods</title>
|
||||
<para>
|
||||
Abstract private methods were supported between PHP 5.0.0 and PHP 5.0.4,
|
||||
but were then disallowed on the grounds that the behaviours of
|
||||
<literal>private</literal> and <literal>abstract</literal> are mutually
|
||||
exclusive.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.oop-modifiers">
|
||||
<title>Access modifiers in interfaces</title>
|
||||
<para>
|
||||
Under PHP 5.0, function declarations in interfaces were treated in exactly
|
||||
the same way as function declarations in classes. This has not been the
|
||||
case since October 2004, at which point only the <literal>public</literal>
|
||||
access modifier was allowed in interface function declarations. Since
|
||||
April 2005 - which pre-dates the PHP 5.0b1 release - the
|
||||
<literal>static</literal> modifier has also been allowed. However, the
|
||||
<literal>protected</literal> and <literal>private</literal> modifiers will
|
||||
now throw an <constant>E_ERROR</constant>, as will
|
||||
<literal>abstract</literal>. Note that this change should not affect your
|
||||
existing code, as none of these modifiers makes sense in the context of
|
||||
interfaces anyway.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.oop-inheritance">
|
||||
<title>Changes in inheritance rules</title>
|
||||
<para>
|
||||
Under PHP 5.0, it was possible to have a function declaration in a derived
|
||||
class that did not match the declaration of the same function in the base
|
||||
class, e.g.
|
||||
</para>
|
||||
<informalexample>
|
||||
<para>
|
||||
This code will cause an <constant>E_STRICT</constant> error to be emitted
|
||||
under PHP 5.1.x.
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class Base {
|
||||
function &return_by_ref() {
|
||||
$r = 1;
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
function return_by_ref() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.oop-constants">
|
||||
<title>Class constants</title>
|
||||
<para>
|
||||
Under PHP 5.0.x, the following code was valid:
|
||||
</para>
|
||||
<informalexample>
|
||||
<para>
|
||||
Under PHP 5.1.x, redefinition of a class constant will throw a fatal
|
||||
<constant>E_ERROR</constant>.
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class test {
|
||||
const foobar = 'foo';
|
||||
const foobar = 'bar';
|
||||
}
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.extensions">
|
||||
<title>Extensions</title>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.extensions-gone">Extensions that are gone
|
||||
from the PHP core</link>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.extensions-constants">Class constants in new
|
||||
PHP 5.1.x extensions</link>
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<section xml:id="migration51.extensions-gone">
|
||||
<title>Extensions that are gone from the PHP core</title>
|
||||
<para>
|
||||
One of the first things you're likely to notice when you download PHP 5.1.x
|
||||
is that several of the older extensions have disappeared. Those extensions
|
||||
that are still actively maintained are available in the PHP Extension
|
||||
Community Library (PECL), at
|
||||
<link xlink:href="&url.pecl;">&url.pecl;</link>.
|
||||
</para>
|
||||
<table>
|
||||
<title>Removed extensions</title>
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Extension</entry>
|
||||
<entry>Alternative/Status</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>ext/cpdf</entry>
|
||||
<entry>pecl/pdflib</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><link linkend="ref.dbx">ext/dbx</link></entry>
|
||||
<entry>pecl/dbx</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><link linkend="ref.dio">ext/dio</link></entry>
|
||||
<entry>pecl/dio</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>ext/fam</entry>
|
||||
<entry>Not actively maintained</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><link linkend="ref.ingres">ext/ingres_ii</link></entry>
|
||||
<entry>pecl/ingres</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>ext/ircg</entry>
|
||||
<entry>Not actively maintained</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>ext/mcve</entry>
|
||||
<entry>pecl/mcve</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>ext/mnogosearch</entry>
|
||||
<entry>Not actively maintained</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>ext/oracle</entry>
|
||||
<entry>
|
||||
<link linkend="ref.oci8">ext/oci8</link> or
|
||||
<link linkend="ref.pdo-oci">ext/pdo_oci</link>
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>ext/ovrimos</entry>
|
||||
<entry>Not actively maintained</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>ext/pfpro</entry>
|
||||
<entry>Not actively maintained</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>ext/w32api</entry>
|
||||
<entry><link xlink:href="&url.pecl.package;ffi">pecl/ffi</link></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>ext/yp</entry>
|
||||
<entry>Not actively maintained</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>ext/activescript</entry>
|
||||
<entry>
|
||||
<link xlink:href="&url.pecl.package;activescript">pecl/activescript</link>
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
<para>
|
||||
Modules in PECL that are not actively maintained (i.e. have not been
|
||||
supported for some time, have no active maintainer working on them
|
||||
currently, and do not have any PECL package releases), are still available
|
||||
in SVN at <link xlink:href="&url.php.svn;pecl">&url.php.svn;pecl</link>.
|
||||
However, unreleased PHP modules are by their nature unsupported, and your
|
||||
mileage may vary when attempting to install or use them.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.extensions-constants">
|
||||
<title>Class constants in new PHP 5.1.x extensions</title>
|
||||
<para>
|
||||
The Zend Engine 2.1 API allows extension developers to declare class
|
||||
constants in object oriented extensions. New extensions written for PHP
|
||||
5.1.x, including <link linkend="ref.spl">SPL</link>,
|
||||
<link linkend="intro.pdo">PDO</link>,
|
||||
<link linkend="book.xmlreader">XMLReader</link> and
|
||||
<link linkend="ref.datetime">date</link>, have their constants in
|
||||
the format <constant>PDO::CLASS_CONSTANT</constant> rather than in the C
|
||||
format <constant>PDO_CLASS_CONSTANT</constant> in order to minimise
|
||||
pollution of the global namespace in PHP.
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.datetime">
|
||||
<title>Date/time support</title>
|
||||
<para>
|
||||
Date/time support has been fully rewritten in PHP 5.1.x, and no longer uses
|
||||
the system settings to 'know' the timezone in operation. It will instead
|
||||
utilize, in the following order:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
The timezone set using the <function>date_default_timezone_set</function>
|
||||
function (if any)
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
The TZ environment variable (if non empty)
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
"magical" guess (if the operating system supports it)
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
If none of the above options succeeds, UTC
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<informalexample>
|
||||
<para>
|
||||
To ensure accuracy (and avoid an <constant>E_STRICT</constant> warning),
|
||||
you will need to define your timezone in your <filename>php.ini</filename>
|
||||
using the following format:
|
||||
</para>
|
||||
<para>
|
||||
date.timezone = Europe/London
|
||||
</para>
|
||||
</informalexample>
|
||||
<para>
|
||||
The supported timezones are listed, in this format, in the
|
||||
<link linkend="timezones">timezones appendix</link>.
|
||||
</para>
|
||||
<para>
|
||||
Also note that <function>strtotime</function> now returns &false; on
|
||||
failure, instead of -1.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.databases">
|
||||
<title>Changes in database support</title>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.databases-pdo">PDO overview</link>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.databases-mysql">Changes in MySQL support</link>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link linkend="migration51.databases-sqlite">Changes in SQLite support</link>
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<section xml:id="migration51.databases-pdo">
|
||||
<title>PDO overview</title>
|
||||
<para>
|
||||
<link linkend="intro.pdo">PHP Data Objects (PDO)</link> were introduced as a
|
||||
PECL extension under PHP 5.0, and became part of the core PHP distribution
|
||||
in PHP 5.1.x. The PDO extension provides a consistent interface for database
|
||||
access, and is used alongside database-specific PDO drivers. Each driver
|
||||
may also have database-specific functions of its own, but basic data
|
||||
access functionality such as issuing queries and fetching data is covered
|
||||
by PDO functions, using the driver named in
|
||||
<function>PDO::__construct</function>.
|
||||
</para>
|
||||
<para>
|
||||
Note that the PDO extension, and its drivers, are intended to be built as
|
||||
shared extensions. This will enable straightforward driver upgrades from
|
||||
PECL, without forcing you to rebuild all of PHP.
|
||||
</para>
|
||||
<para>
|
||||
At the point of the PHP 5.1.x release, PDO is more than ready for widespread
|
||||
testing and could be adopted in most situations. However, it is important
|
||||
to understand that PDO and its drivers are comparatively young and may be
|
||||
missing certain database-specific features; evaluate PDO carefully before
|
||||
you use it in new projects.
|
||||
</para>
|
||||
<para>
|
||||
Legacy code will generally rely on the pre-existing database extensions,
|
||||
which are still maintained.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.databases-mysql">
|
||||
<title>Changes in MySQL support</title>
|
||||
<para>
|
||||
In PHP 4, MySQL 3 support was built-in. With the release of PHP 5.0 there
|
||||
were two MySQL extensions, named 'mysql' and 'mysqli', which were designed
|
||||
to support MySQL < 4.1 and MySQL 4.1 and up, respectively. With the
|
||||
introduction of PDO, which provides a very fast interface to all the
|
||||
database APIs supported by PHP, the PDO_MYSQL driver can support any of
|
||||
the current versions (MySQL 3, 4 or 5) in PHP code written for PDO,
|
||||
depending on the MySQL library version used during compilation. The older
|
||||
MySQL extensions remain in place for reasons of back compatibility, but
|
||||
are not enabled by default.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="migration51.databases-sqlite">
|
||||
<title>Changes in SQLite support</title>
|
||||
<para>
|
||||
In PHP 5.0.x, SQLite 2 support was provided by the built-in sqlite
|
||||
extension, which was also available as a PECL extension in PHP 4.3 and PHP
|
||||
4.4. With the introduction of PDO, the sqlite extension doubles up to act
|
||||
as a 'sqlite2' driver for PDO; it is due to this that the sqlite extension
|
||||
in PHP 5.1.x has a dependency upon the PDO extension.
|
||||
</para>
|
||||
<para>
|
||||
PHP 5.1.x ships with a number of alternative interfaces to sqlite:
|
||||
</para>
|
||||
<para>
|
||||
The sqlite extension provides the "classic" sqlite procedural/OO API that
|
||||
you may have used in prior versions of PHP. It also provides the PDO
|
||||
'sqlite2' driver, which allows you to access legacy SQLite 2 databases
|
||||
using the PDO API.
|
||||
</para>
|
||||
<para>
|
||||
PDO_SQLITE provides the 'sqlite' version 3 driver. SQLite version 3 is
|
||||
vastly superior to SQLite version 2, but the file formats of the two
|
||||
versions are not compatible.
|
||||
</para>
|
||||
<para>
|
||||
If your SQLite-based project is already written and working against
|
||||
earlier PHP versions, then you can continue to use ext/sqlite without
|
||||
problems, but will need to explicitly enable both PDO and sqlite. New
|
||||
projects should use PDO and the 'sqlite' (version 3) driver, as this is
|
||||
faster than SQLite 2, has improved locking concurrency, and supports both
|
||||
prepared statements and binary columns natively.
|
||||
</para>
|
||||
<para>
|
||||
You must enable PDO to use the SQLite extension. If you want to build the
|
||||
PDO extension as a shared extension, then the SQLite extension must also
|
||||
be built shared. The same holds true for any extension that provides a PDO
|
||||
driver
|
||||
</para>
|
||||
</section>
|
||||
</section> <!-- end of migration51.databases -->
|
||||
|
||||
<section xml:id="migration51.errorcheck">
|
||||
<title>Checking for <constant>E_STRICT</constant></title>
|
||||
<informalexample>
|
||||
<para>
|
||||
If you only have a single script to check, you can pick up
|
||||
<constant>E_STRICT</constant> errors using PHP's commandline lint
|
||||
facility:
|
||||
</para>
|
||||
<programlisting role="shell">
|
||||
php -d error_reporting=4095 -l script_to_check.php
|
||||
</programlisting>
|
||||
<para>
|
||||
For larger projects, the shell script below will achieve the same task:
|
||||
</para>
|
||||
<programlisting role="shell">
|
||||
<![CDATA[
|
||||
#!/bin/sh
|
||||
|
||||
directory=$1
|
||||
|
||||
shift
|
||||
|
||||
# These extensions are checked
|
||||
extensions="php inc"
|
||||
|
||||
check_file ()
|
||||
{
|
||||
echo -ne "Doing PHP syntax check on $1 ..."
|
||||
|
||||
# Options:
|
||||
ERRORS=`/www/php/bin/php -d display_errors=1 -d html_errors=0 -d error_prepend_string=" " -d error_append_string=" " -d error_reporting=4095 -l $1 | grep -v "No syntax errors detected"`
|
||||
|
||||
if test -z "$ERRORS"; then
|
||||
echo -ne "OK."
|
||||
else
|
||||
echo -e "Errors found!\n$ERRORS"
|
||||
fi
|
||||
|
||||
echo
|
||||
}
|
||||
|
||||
# loop over remaining file args
|
||||
for FILE in "$@" ; do
|
||||
for ext in $extensions; do
|
||||
if echo $FILE | grep "\.$ext$" > /dev/null; then
|
||||
if test -f $FILE; then
|
||||
check_file "$FILE"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</section>
|
||||
|
||||
</appendix>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -31,15 +31,6 @@
|
|||
versions in production environments.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
&manual.migration.seealso;
|
||||
<link linkend="migration5">5.0.x</link>,
|
||||
<link linkend="migration51">5.1.x</link>,
|
||||
<link linkend="migration52">5.2.x</link>,
|
||||
<link linkend="migration53">5.3.x</link>,
|
||||
<link linkend="migration54">5.4.x</link> and
|
||||
<link linkend="migration55">5.5.x</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
</appendix>
|
||||
|
||||
|
|
|
@ -31,17 +31,6 @@
|
|||
be considered, and code should be tested before switching PHP versions in
|
||||
production environments.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
&manual.migration.seealso;
|
||||
<link linkend="migration5">5.0.x</link>,
|
||||
<link linkend="migration51">5.1.x</link>,
|
||||
<link linkend="migration52">5.2.x</link>,
|
||||
<link linkend="migration53">5.3.x</link>,
|
||||
<link linkend="migration54">5.4.x</link>,
|
||||
<link linkend="migration55">5.5.x</link> and
|
||||
<link linkend="migration56">5.6.x</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
</appendix>
|
||||
|
||||
|
|
|
@ -93,8 +93,7 @@
|
|||
<function>set_magic_quotes_runtime</function>, along with its alias
|
||||
<function>magic_quotes_runtime</function>, have been removed. They were
|
||||
deprecated in PHP 5.3.0, and became effectively non-functional with the
|
||||
removal of magic quotes
|
||||
<link linkend="migration54.incompatible">in PHP 5.4.0</link>.
|
||||
removal of magic quotes in PHP 5.4.0.
|
||||
</para>
|
||||
</sect3>
|
||||
|
||||
|
|
|
@ -24,13 +24,6 @@
|
|||
|
||||
<para>
|
||||
&manual.migration.seealso;
|
||||
<link linkend="migration5">5.0.x</link>,
|
||||
<link linkend="migration51">5.1.x</link>,
|
||||
<link linkend="migration52">5.2.x</link>,
|
||||
<link linkend="migration53">5.3.x</link>,
|
||||
<link linkend="migration54">5.4.x</link>,
|
||||
<link linkend="migration55">5.5.x</link>,
|
||||
<link linkend="migration56">5.6.x</link> and
|
||||
<link linkend="migration70">7.0.x</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
|
|
@ -22,13 +22,6 @@
|
|||
|
||||
<para>
|
||||
&manual.migration.seealso;
|
||||
<link linkend="migration5">5.0.x</link>,
|
||||
<link linkend="migration51">5.1.x</link>,
|
||||
<link linkend="migration52">5.2.x</link>,
|
||||
<link linkend="migration53">5.3.x</link>,
|
||||
<link linkend="migration54">5.4.x</link>,
|
||||
<link linkend="migration55">5.5.x</link>,
|
||||
<link linkend="migration56">5.6.x</link>,
|
||||
<link linkend="migration70">7.0.x</link> and
|
||||
<link linkend="migration71">7.1.x</link>.
|
||||
</para>
|
||||
|
|
|
@ -23,13 +23,6 @@
|
|||
|
||||
<para>
|
||||
&manual.migration.seealso;
|
||||
<link linkend="migration5">5.0.x</link>,
|
||||
<link linkend="migration51">5.1.x</link>,
|
||||
<link linkend="migration52">5.2.x</link>,
|
||||
<link linkend="migration53">5.3.x</link>,
|
||||
<link linkend="migration54">5.4.x</link>,
|
||||
<link linkend="migration55">5.5.x</link>,
|
||||
<link linkend="migration56">5.6.x</link>,
|
||||
<link linkend="migration70">7.0.x</link>,
|
||||
<link linkend="migration71">7.1.x</link> and
|
||||
<link linkend="migration72">7.2.x</link>.
|
||||
|
|
Loading…
Reference in a new issue