1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968
|
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 328430 $ -->
<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> and
<link linkend="migration55">5.5.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>
mail.force_extra_parameters - 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
problems and some others. For more information, read the <link
linkend="faq.databases.mysql.php5">FAQ entry</link>.
</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 <link linkend="ref.sqlite">SQLite</link> 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 compatability 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
-->
|