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 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034
|
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 328430 $ -->
<appendix xml:id="migration52" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Migrating from PHP 5.1.x to PHP 5.2.x</title>
<para>
&manual.migration.seealso;
<link linkend="migration5">5.0.x</link>,
<link linkend="migration51">5.1.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="migration52.changes">
<title>What has changed in PHP 5.2.x</title>
<para>
Most improvements in PHP 5.2.x have no impact on existing code. There are
a <link linkend="migration52.incompatible">few incompatibilities</link>
and <link linkend="migration52.error-messages">new error messages</link>
that should be considered, and code should be tested before switching PHP
versions in production environments.
</para>
<para>
If the system is being upgraded from PHP 5.0.x, the manual section titled
<link linkend="migration51">Upgrade Notes for PHP 5.1.x</link>
should also be read.
</para>
<para>
Similarly, if the system is being upgraded from PHP 4, the manual section
titled <link linkend="migration5">Migrating from PHP 4 to PHP 5</link>
should be read as well.
</para>
</section>
<section xml:id="migration52.incompatible">
<title>Backward Incompatible Changes</title>
<para>
Although most existing PHP 5 code should work without changes, you should
pay attention to the following backward incompatible changes:
</para>
<itemizedlist>
<listitem>
<simpara>
<function>getrusage</function> returns &null; when passed
incompatible arguments as of PHP 5.2.1.
</simpara>
</listitem>
<listitem>
<simpara>
<function>ZipArchive::setCommentName</function>
returns &true; on success as of PHP 5.2.1.
</simpara>
</listitem>
<listitem>
<simpara>
<function>ZipArchive::setCommentIndex</function>
returns &true; on success as of PHP 5.2.1.
</simpara>
</listitem>
<listitem>
<simpara>
<function>SplFileObject::getFilename</function> returns
the filename, not relative/path/to/file, as of PHP 5.2.1.
</simpara>
</listitem>
<listitem>
<simpara>
Changed priority of <varname>PHPRC</varname> environment variable on Win32
</simpara>
<simpara>
The <varname>PHPRC</varname> environment variable now takes priority over the path stored
in the Windows registry.
</simpara>
</listitem>
<listitem>
<simpara>
CLI SAPI no longer checks cwd for &php.ini; or the <filename>php-cli.ini</filename> file
</simpara>
<simpara>
In PHP 5.1.x an undocumented feature was added that made the CLI binary check
the current working directory for a PHP configuration file, potentially
leading to unpredictable behavior if an unexpected configuration file were
read. This functionality was removed in 5.2.0, and PHP will no longer search
CWD for the presence of &php.ini; or <filename>php-cli.ini</filename> files.
See also the <link linkend="features.commandline">command line</link> section
of the manual.
</simpara>
</listitem>
<listitem>
<simpara>
Added a warning when performing modulus 0 operations
</simpara>
<simpara>
In earlier versions of PHP, performing integer % 0 did not emit any
warning messages, instead returning an unexpected return value of &false;.
As of PHP 5.2.0, this operation will emit an <constant>E_WARNING</constant>,
as is the case in all other instances where division by zero is performed.
</simpara>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
print 10 % 0;
/* Warning: Division by zero in filename on line n */
?>
]]>
</programlisting>
</informalexample>
</listitem>
<listitem>
<simpara>
Changed <link linkend="object.tostring">__toString()</link> to be called wherever
applicable.
</simpara>
<simpara>
The magic method <link linkend="object.tostring">__toString()</link> will now be called
in a string context, that is, anywhere an object is used as a
string.
</simpara>
<simpara>
The fallback of returning a string that contains the
object identifier was dropped in PHP 5.2.0. It became
problematic because an object identifier cannot be considered
unique. This change will mean that your application is flawed if you
have relied on the object identifier as a return value. An attempt
to use that value as a string will now result in a catchable fatal
error.
</simpara>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
class foo {}
$foo = new foo;
print $foo;
/* Catchable fatal error: Object of class foo could
not be converted to string in filename on line n */
?>
]]>
</programlisting>
</informalexample>
<simpara>
Even with <link linkend="object.tostring">__toString()</link>, objects cannot be used as
array indices or keys. We may add built-in hash support for this at
a later date, but as of PHP 5.2.x you will need to either provide your
own hashing or use the new SPL function
<function>spl_object_hash</function>.
</simpara>
<simpara>
Exceptions can not be thrown from
<link linkend="object.tostring">__toString()</link> methods.
</simpara>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
class foo {
public function __toString() {
throw new Exception;
}
}
try {
print new foo;
/* Fatal error: Method foo::__toString() must
not throw an exception in filename on line n */
} catch(Exception $e) {}
?>
]]>
</programlisting>
</informalexample>
</listitem>
<listitem>
<simpara>
Dropped abstract static class functions.
</simpara>
<simpara>
Due to an oversight, PHP 5.0.x and 5.1.x allowed abstract static
functions in classes. As of PHP 5.2.x, only interfaces can have them.
</simpara>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
abstract class foo {
abstract static function bar();
/* Strict Standards: Static function foo::bar()
should not be abstract in filename on line n */
}
?>
]]>
</programlisting>
</informalexample>
</listitem>
<listitem>
<simpara>
<link linkend="ref.oci8">Oracle extension</link> requires at least Oracle
10 on Windows.
</simpara>
</listitem>
<listitem>
<simpara>
Added RFC2397 (<literal>data:</literal> stream) support.
</simpara>
<simpara>
The introduction of the 'data' URL scheme has the potential to lead to a
change of behavior under Windows. If you are working with a <acronym>NTFS</acronym>
file system and making use of meta streams in your application, and if you
just happen to be using a file with the name 'data:' that is accessed without
any path information - it won't work any more. The fix is to use the 'file:'
protocol when accessing it.
</simpara>
<simpara>
See also <link xlink:href="&url.rfc;2397">RFC 2397</link>
</simpara>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
/* when allow_url_include is OFF (default) */
include "data:;base64,PD9waHAgcGhwaW5mbygpOz8+";
/* Warning: include(): URL file-access is disabled
in the server configuration in filename on line n */
?>
]]>
</programlisting>
</informalexample>
</listitem>
<listitem>
<simpara>
Regression in <literal>glob()</literal> patterns
</simpara>
<simpara>
In version 5.2.4 a security fix caused a regression for patterns of
the form "/foo/*/bar/*". Since version 5.2.5 instead of raising a warning the
<literal>glob()</literal> function will return &false; when
<literal>openbase_dir</literal> restrictions are violated.
</simpara>
</listitem>
</itemizedlist>
</section>
<section xml:id="migration52.error-messages">
<title>New Error Messages</title>
<para>
Below are the new error messages that have not been discussed
elsewhere in this document.
</para>
<para>
<example>
<title>In PHP Core</title>
<programlisting role="php">
<![CDATA[
<?php
echo " ";
session_regenerate_id();
/* Warning: session_regenerate_id(): Cannot regenerate
session id - headers already sent in filename on line n */
str_word_count("string", 4);
/* Warning: str_word_count(): Invalid format value 4
in filename on line n */
strripos("foo", "f", 4);
/* Notice: strripos(): Offset is greater than the
length of haystack string in filename on line n */
strrpos("foo", "f", 4);
/* Notice: strrpos(): Offset is greater than the
length of haystack string in filename on line n */
/* As of PHP 5.2.1, when allow_url_include is OFF (default) */
include "php://input";
/* Warning: include(): URL file-access is disabled
in the server configuration in filename on line n */
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title><link linkend="language.oop5">Object Oriented Code</link> in PHP Core</title>
<programlisting role="php">
<![CDATA[
<?php
interface foo {
}
class bar implements foo, foo {
}
/* Fatal error: Class bar cannot implement previously
implemented interface foo in filename on line n */
class foo {
public $bar;
function __get($var)
{
return $this->bar;
}
}
$foo = new foo;
$bar =& $foo->prop;
/* Notice: Indirect modification of overloaded property
foo::$prop has no effect in filename on line n */
class foo implements iterator {
public function current() {
}
public function next() {
}
public function key() {
}
public function valid() {
}
public function rewind() {
}
}
$foo = new foo();
foreach($foo as &$ref) {}
/* Fatal error: An iterator cannot be used with foreach
by reference in filename on line n */
class foo {
private function __construct() {
}
}
class bar extends foo {
public function __construct() {
parent::__construct();
/* Fatal error: Cannot call private
foo::__construct() in filename on line n */
}
}
new bar;
stream_filter_register("", "class");
/* Warning: stream_filter_register(): Filter name
cannot be empty in filename on line n */
stream_filter_register("filter", "");
/* Warning: stream_filter_register(): Class name
cannot be empty in filename on line n */
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>In the <link linkend="ref.bzip2">bzip2</link> Extension</title>
<programlisting role="php">
<![CDATA[
<?php
bzopen("", "w");
/* Warning: bzopen(): filename cannot be empty
in filename on line n */
bzopen("foo", "a");
/* Warning: bzopen(): 'a' is not a valid mode for
bzopen(). Only 'w' and 'r' are supported in
filename on line n */
$fp = fopen("foo", "w");
bzopen($fp, "r");
/* Warning: bzopen(): cannot read from a stream
opened in write only mode in filename on line n */
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>In the <link linkend="ref.datetime">datetime</link> Extension</title>
<programlisting role="php">
<![CDATA[
<?php
strtotime("today", "now");
/* Warning: strtotime() expects parameter 2 to be
long, string given in filename on line n */
/* As of PHP 5.2.1 */
new DateTime(new stdclass);
/* Fatal error: Uncaught exception 'Exception' with
message 'DateTime::__construct() expects parameter
1 to be string, object given' in filename:n */
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>In the <link linkend="ref.dbase">dBase</link> Extension</title>
<programlisting role="php">
<![CDATA[
<?php
dbase_open("foo", -1);
/* Warning: Invalid access mode -1 in filename on line n */
/* As of PHP 5.2.1 */
dbase_open("foo", null);
/* Warning: The filename cannot be empty in filename on line n */
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>In the <link linkend="ref.mcrypt">mcrypt</link> Extension</title>
<programlisting role="php">
<![CDATA[
<?php
$key = "this is a secret key";
$td = mcrypt_module_open('tripledes', '', 'ecb', '');
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td),
MCRYPT_RAND);
mcrypt_generic_init($td, $key, $iv);
$encrypted_data = mcrypt_generic($td, "");
/* Warning: mcrypt_generic(): An empty string was
passed in filename on line n */
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>In the <link linkend="ref.oci8">oci8</link> Extension</title>
<programlisting role="php">
<![CDATA[
<?php
oci_connect("user", "pass", "db", "bogus_charset");
/* Warning: Invalid character set name:
bogus_charset in filename on line n */
$oci = oci_connect("user", "pass", "db");
oci_password_change($oci, "", "old", "new");
/* Warning: username cannot be empty in filename
on line n */
oci_password_change($oci, "user", "", "new");
/* Warning: old password cannot be empty in filename
on line n */
oci_password_change($oci, "user", "old", "");
/* Warning: new password cannot be empty in filename
on line n */
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>In the <link linkend="ref.spl">SPL</link> Extension</title>
<programlisting role="php">
<![CDATA[
<?php
$obj = new SplFileObject(__FILE__);
$obj->fgetcsv("foo");
/* Warning: SplFileObject::fgetcsv(): delimiter must
be a character in filename on line n */
$obj->fgetcsv(",", "foo");
/* Warning: SplFileObject::fgetcsv(): enclosure must
be a character in filename on line n */
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>In the <link linkend="ref.sem">Semaphore</link> (sysvmsg) extension</title>
<programlisting role="php">
<![CDATA[
<?php
/* Warning: maximum size of the message has to be
greater then zero in filename on line n */
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>A 5.2.1+ <link linkend="ref.zip">Zip</link> Example</title>
<programlisting role="php">
<![CDATA[
<?php
$obj = new ZipArchive();
$obj->open('archive.zip');
$obj->setCommentName('', 'comment');
/* Notice: ZipArchive::setCommentName(): Empty string
as entry name in filename on line n */
/* As of PHP 5.2.1 */
$obj->getCommentName('');
/* Notice: ZipArchive::getCommentName(): Empty string
as entry name in filename on line n */
?>
]]>
</programlisting>
</example>
</para>
</section>
<section xml:id="migration52.datetime">
<title>Changes in PHP <link linkend="ref.datetime">datetime</link>
support</title>
<para>
Since PHP 5.1.0, there has been an extension named <literal>date</literal>
in the PHP core. This is the new implementation of PHP's datetime support.
Although it will attempt to guess your system's timezone setting, you
should set the timezone manually. You can do this in any of three ways:
</para>
<itemizedlist>
<listitem>
<simpara>
in your &php.ini; using the
<link linkend="ini.date.timezone">date.timezone</link> INI directive
</simpara>
</listitem>
<listitem>
<simpara>
on your system using the <varname>TZ</varname> environmental variable
</simpara>
</listitem>
<listitem>
<simpara>
from your script using the convenience function
<function>date_default_timezone_set</function>
</simpara>
</listitem>
</itemizedlist>
<para>
All supported <link linkend="timezones">timezones</link> are listed
in the PHP Manual.
</para>
<para>
With the advent of PHP 5.2.x, there are <type>object</type> representations of the
date and timezone, named <literal>DateTime</literal> and <literal>DateTimeZone</literal> respectively.
The methods map to existing procedural date functions.
</para>
</section>
<section xml:id="migration52.parameters">
<title>New Parameters</title>
<para>
Some functions were given new, optional, parameters in PHP 5.2.x:
</para>
<para>PHP Core:</para>
<itemizedlist>
<listitem>
<simpara>
<function>htmlentities</function>
- added <parameter>double_encode</parameter> in PHP 5.2.3.
</simpara>
</listitem>
<listitem>
<simpara>
<function>htmlspecialchars</function>
- added <parameter>double_encode</parameter> in PHP 5.2.3.
</simpara>
</listitem>
<listitem>
<simpara>
<function>base64_decode</function>
- added <parameter>strict</parameter>
</simpara>
</listitem>
<listitem>
<simpara>
<function>setcookie</function>
- added <parameter>httponly</parameter>
</simpara>
</listitem>
<listitem>
<simpara>
<function>setrawcookie</function>
- added <parameter>httponly</parameter>
</simpara>
</listitem>
<listitem>
<simpara>
<function>session_set_cookie_params</function>
- added <parameter>httponly</parameter>
</simpara>
</listitem>
<listitem>
<simpara>
<function>memory_get_usage</function>
- added <parameter>real_usage</parameter>
</simpara>
</listitem>
<listitem>
<simpara>
<function>get_loaded_extensions</function>
- added <parameter>zend_extensions</parameter> in PHP 5.2.4
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.curl">curl</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>curl_multi_info_read</function>
- added <parameter>msgs_in_queue</parameter>
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.datetime">datetime</link></para>
<itemizedlist>
<listitem>
<simpara>
<function>date</function>
- added "u" (milliseconds) format character in PHP 5.2.2
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.imap">imap</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>imap_open</function>
- added <parameter>n_retries</parameter>
</simpara>
</listitem>
<listitem>
<simpara>
<function>imap_reopen</function>
- added <parameter>n_retries</parameter>
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.mbstring">mbstring</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>mb_strrpos</function>
- added <parameter>offset</parameter>
</simpara>
<warning>
<simpara>
The <parameter>offset</parameter> parameter was put in the position
the <parameter>encoding</parameter> parameter used to be.
Backward compatibility has been
provided by allowing <parameter>encoding</parameter> to be specified
as the third parameter. Using this backward compatibility mode is
not recommended because it will be removed in a future release of PHP.
</simpara>
</warning>
</listitem>
</itemizedlist>
<para><link linkend="ref.ming">ming</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>SWFMovie::streamMP3</function>
- added <parameter>skip</parameter> in PHP 5.2.1
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.openssl">openssl</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>openssl_verify</function>
- added <parameter>signature_algo</parameter>
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.pgsql">pgsql</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>pg_escape_bytea</function>
- added <parameter>connection</parameter>
</simpara>
</listitem>
<listitem>
<simpara>
<function>pg_escape_string</function>
- added <parameter>connection</parameter>
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.simplexml">simplexml</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>SimpleXMLElement::__construct</function>
- added <parameter>is_prefix</parameter>
</simpara>
</listitem>
<listitem>
<simpara>
<function>SimpleXMLElement::attributes</function>
- added <parameter>is_prefix</parameter>
</simpara>
</listitem>
<listitem>
<simpara>
<function>SimpleXMLElement::children</function>
- added <parameter>is_prefix</parameter>
</simpara>
</listitem>
<listitem>
<simpara>
<function>simplexml_load_file</function>
- added <parameter>is_prefix</parameter>
</simpara>
</listitem>
<listitem>
<simpara>
<function>simplexml_load_string</function>
- added <parameter>is_prefix</parameter>
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.spl">spl</link>:</para>
<itemizedlist>
<listitem>
<simpara>
array iterator_to_array(Traversable it [, bool use_keys = true])
- added <parameter>use_keys</parameter> in PHP 5.2.1
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="book.xmlreader">xmlreader</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>XMLReader::open</function>
- added <parameter>encoding</parameter>
and <parameter>options</parameter>
</simpara>
</listitem>
<listitem>
<simpara>
<function>XMLReader::XML</function>
- added <parameter>encoding</parameter>
and <parameter>options</parameter>
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.xmlwriter">XMLWriter</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>xmlwriter_write_element</function>
- the <parameter>content</parameter> became optional in PHP 5.2.3
</simpara>
</listitem>
<listitem>
<simpara>
<function>xmlwriter_write_element_ns</function>
- the <parameter>content</parameter> became optional in PHP 5.2.3
</simpara>
</listitem>
</itemizedlist>
</section>
<section xml:id="migration52.functions">
<title>New Functions</title>
<para>
PHP 5.2.x introduced some new functions:
</para>
<para>PHP Core:</para>
<itemizedlist>
<listitem>
<simpara>
<function>array_fill_keys</function>
- Create an array using the elements of the first parameter as keys,
each initialized to <literal>val</literal>
</simpara>
</listitem>
<listitem>
<simpara>
<function>error_get_last</function>
- Get the last occurred error as associative array. Returns &null;
if there hasn't been an error yet
</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>memory_get_peak_usage</function>
- Returns the peak allocated by PHP memory
</simpara>
</listitem>
<listitem>
<simpara>
<function>sys_get_temp_dir</function>
- Returns directory path used for temporary files. (Added in 5.2.1)
</simpara>
</listitem>
<listitem>
<simpara>
<function>timezone_abbreviations_list</function>
- Returns associative array containing DST, offset and the timezone name
</simpara>
</listitem>
<listitem>
<simpara>
<function>timezone_identifiers_list</function>
- Returns numerically indexed array with all timezone identifiers
</simpara>
</listitem>
<listitem>
<simpara>
<function>timezone_name_from_abbr</function>
- Returns the timezone name from abbreviation
</simpara>
</listitem>
<listitem>
<simpara>
<function>stream_socket_shutdown</function>
- Causes all or part of a full-duplex connection on the socket
associated with stream to be shut down. As of PHP 5.2.1.
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.image">Image</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>imagegrabscreen</function>
- Grabs a screenshot of the whole screen. As of PHP 5.2.2.
</simpara>
</listitem>
<listitem>
<simpara>
<function>imagegrabwindow</function>
- Captures a window. As of PHP 5.2.2.
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="book.libxml">libXML</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>libxml_disable_entity_loader</function>
- Disable the ability to load external entities. As of PHP 5.2.11.
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.mbstring">mbstring</link>:</para>
<itemizedlist>
<!--
FIXME: Apparently these two never made it into a release
see bug#41070
<listitem>
<simpara>
<function>mb_list_encodings_alias_names</function>
- Returns an array of all supported entity encodings
</simpara>
</listitem>
<listitem>
<simpara>
<function>mb_list_mime_names</function>
- Returns an array or string of all supported mime names
</simpara>
</listitem>
-->
<listitem>
<simpara>
<function>mb_stripos</function>
- Finds position of first occurrence of a string within another,
case insensitive
</simpara>
</listitem>
<listitem>
<simpara>
<function>mb_stristr</function>
- Finds first occurrence of a string within another, case insensitive
</simpara>
</listitem>
<listitem>
<simpara>
<function>mb_strrchr</function>
- Finds the last occurrence of a character in a string within another
</simpara>
</listitem>
<listitem>
<simpara>
<function>mb_strrichr</function>
- Finds the last occurrence of a character in a string within another,
case insensitive
</simpara>
</listitem>
<listitem>
<simpara>
<function>mb_strripos</function>
- Finds position of last occurrence of a string within another,
case insensitive
</simpara>
</listitem>
<listitem>
<simpara>
<function>mb_strstr</function>
- Finds first occurrence of a string within another
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.ming">ming</link> (As of PHP 5.2.1):</para>
<itemizedlist>
<listitem>
<simpara>
void ming_setSWFCompression(int num)
- Sets output compression
</simpara>
</listitem>
<listitem>
<simpara>
void swfmovie::namedanchor(string name)
- Creates anchor
</simpara>
</listitem>
<listitem>
<simpara>
void swfmovie::protect([string password])
- Protects
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.openssl">openssl</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>openssl_csr_get_public_key</function>
- Extracts public key from a CERT and prepares it for use
</simpara>
</listitem>
<listitem>
<simpara>
<function>openssl_csr_get_subject</function>
- Returns the subject of a CERT
</simpara>
</listitem>
<listitem>
<simpara>
<function>openssl_pkey_get_details</function>
- Returns an array with the key details (bits, pkey, type)
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.spl">spl</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>spl_object_hash</function>
- Return hash id for given object
</simpara>
</listitem>
<listitem>
<simpara>
int iterator_apply(Traversable it, mixed function [, mixed params])
- Calls a function for every element in an iterator
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.pcre">pcre</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>preg_last_error</function>
- Returns the error code of the last regex execution
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.pgsql">pgsql</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>pg_field_table</function>
- Returns the name of the table field belongs to, or table's oid
if <literal>oid_only</literal> is &true;
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.posix">posix</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>posix_initgroups</function>
- Calculate the group access list for the user specified in name
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.gmp">gmp</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>gmp_nextprime</function>
- Finds next prime number
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.xmlwriter">xmlwriter</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>xmlwriter_full_end_element</function>
- End current element - returns &false; on error
</simpara>
</listitem>
<listitem>
<simpara>
<function>xmlwriter_write_raw</function>
- Write text - returns &false; on error
</simpara>
</listitem>
<listitem>
<simpara>
<function>xmlwriter_start_dtd_entity</function>
- Create start DTD Entity - returns &false; on error
</simpara>
</listitem>
<listitem>
<simpara>
<function>xmlwriter_end_dtd_entity</function>
- End current DTD Entity - returns &false; on error
</simpara>
</listitem>
<listitem>
<simpara>
<function>xmlwriter_write_dtd_entity</function>
- Write full DTD Entity tag - returns &false; on error
</simpara>
</listitem>
</itemizedlist>
</section>
<section xml:id="migration52.methods">
<title>New Methods</title>
<para>
New methods were introduced in 5.2.0:
</para>
<para><link linkend="book.dom">dom</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<function>DOMDocument::registerNodeClass</function>
- Register extended class used to create base node type
</simpara>
</listitem>
<listitem>
<simpara>
<function>DOMElement::setIDAttribute</function>
- Declares the attribute specified by name to be of type ID
</simpara>
</listitem>
<listitem>
<simpara>
<function>DOMElement::setIDAttributeNode</function>
- Declares the attribute specified by node to be of type ID
</simpara>
</listitem>
<listitem>
<simpara>
<function>DOMElement::setIDAttributeNS</function>
- Declares the attribute specified by local name and namespace URI to be
of type ID
</simpara>
</listitem>
<listitem>
<simpara>
<methodname>DOMNode::C14N</methodname>([bool exclusive [, bool with_comments [, array xpath [, array ns_prefixes]]]])
- Canonicalize nodes to a string
</simpara>
</listitem>
<listitem>
<simpara>
<methodname>DOMNode::C14NFile</methodname>(string uri [, bool exclusive [, bool with_comments [, array xpath [, array ns_prefixes]]]])
- Canonicalize nodes to a file
</simpara>
</listitem>
<listitem>
<simpara>
<methodname>DOMNode::getNodePath</methodname>()
- Gets an <literal>xpath</literal> for a node
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.soap">soap</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<methodname>SoapServer::setObject</methodname>(object obj)
- Sets object which will handle SOAP requests
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.spl">spl</link>:</para>
<itemizedlist>
<listitem>
<simpara>
int <methodname>ArrayObject::asort</methodname>(void)
- Sort the entries by values
</simpara>
</listitem>
<listitem>
<simpara>
int <methodname>ArrayObject::ksort</methodname>(void)
- Sort the entries by key
</simpara>
</listitem>
<listitem>
<simpara>
int <methodname>ArrayObject::natcasesort</methodname>(void)
- Sort the entries by key using case insensitive
"natural order" algorithm.
</simpara>
</listitem>
<listitem>
<simpara>
int <methodname>ArrayObject::natsort</methodname>(void)
- Sort the entries by values using "natural order" algorithm.
</simpara>
</listitem>
<listitem>
<simpara>
int <methodname>ArrayObject::uasort</methodname>(callback cmp_function)
- Sort the entries by values using a user defined function
</simpara>
</listitem>
<listitem>
<simpara>
int <methodname>ArrayObject::uksort</methodname>(callback cmp_function)
- Sort the entries by key using a user defined function.
</simpara>
</listitem>
<listitem>
<simpara>
ArrayIterator <methodname>AppendIterator::getArrayIterator</methodname>()
- Get access to inner <literal>ArrayIterator</literal>
</simpara>
</listitem>
<listitem>
<simpara>
int <methodname>AppendIterator::getIteratorIndex</methodname>()
- Get index of iterator
</simpara>
</listitem>
<listitem>
<simpara>
bool <methodname>CachingIterator::getCache</methodname>()
- Return the cache
</simpara>
</listitem>
<listitem>
<simpara>
int <methodname>CachingIterator::getFlags</methodname>()
- Return the internal flags
</simpara>
</listitem>
<listitem>
<simpara>
bool <methodname>CachingIterator::offsetExists</methodname>(mixed index)
- Returns &true; if the requested index exists
</simpara>
</listitem>
<listitem>
<simpara>
string <methodname>CachingIterator::offsetGet</methodname>(mixed index)
- Return the internal cache if used
</simpara>
</listitem>
<listitem>
<simpara>
void <methodname>CachingIterator::offsetSet</methodname>(mixed index, mixed newval)
- Set given index in cache
</simpara>
</listitem>
<listitem>
<simpara>
void <methodname>CachingIterator::offsetUnset</methodname>(mixed index)
- Unset given index in cache
</simpara>
</listitem>
<listitem>
<simpara>
void <methodname>CachingIterator::setFlags</methodname>()
- Set the internal flags
</simpara>
</listitem>
<listitem>
<simpara>
array("delimiter" =>, "enclosure" =>) <methodname>SplFileObject::getCsvControl</methodname>(void)
- Get the delimiter and enclosure character used in <function>fgetcsv</function>
</simpara>
</listitem>
<listitem>
<simpara>
void <methodname>SplFileObject::setCsvControl</methodname>([string delimiter = ',' [, string enclosure = '"']])
- Set the delimiter and enclosure character used in <function>fgetcsv</function>
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.tidy">Tidy</link></para>
<itemizedlist>
<listitem>
<simpara>
tidyNode <methodname>tidyNode::getParent</methodname>()
- Returns the parent node of the current node (Added in PHP 5.2.2)
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="book.xmlreader">XMLReader</link></para>
<itemizedlist>
<listitem>
<simpara>
boolean <function>XMLReader::setSchema</function>
- Use W3C XSD schema to validate the document as it is processed. Activation is
only possible before the first <function>XMLReader::read</function>
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.zip">zip</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<methodname>ZipArchive::addEmptyDir</methodname>()
- Creates an empty directory in the archive
</simpara>
</listitem>
</itemizedlist>
</section>
<section xml:id="migration52.removed-extensions">
<title>Removed Extensions</title>
<para>
These extensions have been moved to PECL and are no longer
part of the PHP distribution. The PECL package version of
these extensions will be created according to user demand.
</para>
<itemizedlist>
<listitem>
<simpara>
<link linkend="ref.filepro">filePro</link>
</simpara>
</listitem>
<listitem>
<simpara>
<link linkend="ref.hwapi">Hyperwave API</link>
</simpara>
</listitem>
</itemizedlist>
</section>
<section xml:id="migration52.new-extensions">
<title>New Extensions</title>
<para>
The following are new extensions added (by default) as of PHP 5.2.0:
</para>
<itemizedlist>
<listitem>
<simpara>
<link linkend="ref.filter">Filter</link>
- validates and filters data, and is designed for use with insecure
data such as user input. This extension is enabled by default; the
default mode RAW does not impact input data in any way.
</simpara>
</listitem>
<listitem>
<simpara>
<link linkend="ref.json">JSON</link>
- implements the JavaScript Object Notation (JSON)
data interchange format. This extension is enabled by default.
</simpara>
</listitem>
<listitem>
<simpara>
<link linkend="ref.zip">Zip</link>
- enables you to transparently read or write ZIP
compressed archives and the files inside them.
</simpara>
</listitem>
</itemizedlist>
</section>
<section xml:id="migration52.classes">
<title>New Classes</title>
<para>
The following classes were introduced in PHP 5.2.0:
</para>
<itemizedlist>
<listitem>
<simpara>
<link linkend="ref.datetime">DateTime</link>
</simpara>
</listitem>
<listitem>
<simpara>
<link linkend="ref.datetime">DateTimeZone</link>
</simpara>
</listitem>
<listitem>
<simpara>
RegexIterator - extends <classname>FilterIterator</classname>;
implements <classname>Iterator</classname>, <classname>Traversable</classname>,
<classname>OuterIterator</classname>
</simpara>
<simpara>
Constants:
</simpara>
<itemizedlist>
<listitem>
<simpara>
<constant>RegexIterator::ALL_MATCHES</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>RegexIterator::GET_MATCH</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>RegexIterator::MATCH</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>RegexIterator::REPLACE</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>RegexIterator::SPLIT</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>RegexIterator::USE_KEY</constant>
</simpara>
</listitem>
</itemizedlist>
<simpara>
Properties:
</simpara>
<itemizedlist>
<listitem>
<simpara>
public <property>replacement</property>
</simpara>
</listitem>
</itemizedlist>
<simpara>
Methods:
</simpara>
<itemizedlist>
<listitem>
<simpara>
RegexIterator::__construct(Iterator it, string regex [, int mode [, int flags [, int preg_flags]]])
- Create an <literal>RegexIterator</literal> from another iterator and a regular expression
</simpara>
</listitem>
<listitem>
<simpara>
bool RegexIterator::accept()
- Match (string)current() against regular expression
</simpara>
</listitem>
<listitem>
<simpara>
bool RegexIterator::getFlags()
- Returns current operation flags
</simpara>
</listitem>
<listitem>
<simpara>
bool RegexIterator::getMode()
- Returns current operation mode
</simpara>
</listitem>
<listitem>
<simpara>
bool RegexIterator::getPregFlags()
- Returns current PREG flags (if in use or &null;)
</simpara>
</listitem>
<listitem>
<simpara>
bool RegexIterator::setFlags(int new_flags)
- Set operation flags
</simpara>
</listitem>
<listitem>
<simpara>
bool RegexIterator::setMode(int new_mode)
- Set new operation mode
</simpara>
</listitem>
<listitem>
<simpara>
bool RegexIterator::setPregFlags(int new_flags)
- Set PREG flags
</simpara>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<simpara>
RecursiveRegexIterator
</simpara>
<simpara>
Constants:
</simpara>
<itemizedlist>
<listitem>
<simpara>
<constant>RecursiveRegexIterator::ALL_MATCHES</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>RecursiveRegexIterator::GET_MATCH</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>RecursiveRegexIterator::MATCH</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>RecursiveRegexIterator::REPLACE</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>RecursiveRegexIterator::SPLIT</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>RecursiveRegexIterator::USE_KEY</constant>
</simpara>
</listitem>
</itemizedlist>
<simpara>
Methods:
</simpara>
<itemizedlist>
<listitem>
<simpara>
RecursiveRegexIterator::__construct(RecursiveIterator it, string regex [, int mode [, int flags [, int preg_flags]]])
- Create an <literal>RecursiveRegexIterator</literal> from another recursive iterator and
a regular expression
</simpara>
</listitem>
<listitem>
<simpara>
RecursiveRegexIterator RecursiveRegexIterator::getChildren()
- Return the inner iterator's children contained in a
<literal>RecursiveRegexIterator</literal>
</simpara>
</listitem>
<listitem>
<simpara>
bool RecursiveRegexIterator::hasChildren()
- Check whether the inner iterator's current element has children
</simpara>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</section>
<section xml:id="migration52.global-constants">
<title>New Global Constants</title>
<para>PHP Core:</para>
<itemizedlist>
<listitem>
<simpara>
<constant>M_EULER</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>M_LNPI</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>M_SQRT3</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>M_SQRTPI</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>PATHINFO_FILENAME</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>PREG_BACKTRACK_LIMIT_ERROR</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>PREG_BAD_UTF8_ERROR</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>PREG_INTERNAL_ERROR</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>PREG_NO_ERROR</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>PREG_RECURSION_LIMIT_ERROR</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>UPLOAD_ERR_EXTENSION</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>STREAM_SHUT_RD</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>STREAM_SHUT_WR</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>STREAM_SHUT_RDWR</constant>
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.curl">curl</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<constant>CURLE_FILESIZE_EXCEEDED</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CURLE_FTP_SSL_FAILED</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CURLE_LDAP_INVALID_URL</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CURLFTPAUTH_DEFAULT</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CURLFTPAUTH_SSL</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CURLFTPAUTH_TLS</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CURLFTPSSL_ALL</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CURLFTPSSL_CONTROL</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CURLFTPSSL_NONE</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CURLFTPSSL_TRY</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CURLOPT_FTP_SSL</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CURLOPT_FTPSSLAUTH</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CURLOPT_TCP_NODELAY</constant>
</simpara>
<simpara>
Added in PHP 5.2.1.
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CURLOPT_TIMEOUT_MS</constant>
</simpara>
<simpara>
Added in PHP 5.2.3
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CURLOPT_CONNECTTIMEOUT_MS</constant>
</simpara>
<simpara>
Added in PHP 5.2.3
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.gmp">GMP</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<constant>GMP_VERSION</constant>
</simpara>
<simpara>
Added in PHP 5.2.2.
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.ming">ming</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<constant>SWFTEXTFIELD_USEFONT</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SWFTEXTFIELD_AUTOSIZE</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SWF_SOUND_NOT_COMPRESSED</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SWF_SOUND_ADPCM_COMPRESSED</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SWF_SOUND_MP3_COMPRESSED</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SWF_SOUND_NOT_COMPRESSED_LE</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SWF_SOUND_NELLY_COMPRESSED</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SWF_SOUND_5KHZ</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SWF_SOUND_11KHZ</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SWF_SOUND_22KHZ</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SWF_SOUND_44KHZ</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SWF_SOUND_8BITS</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SWF_SOUND_16BITS</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SWF_SOUND_MONO</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SWF_SOUND_STEREO</constant>
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.openssl">openssl</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<constant>OPENSSL_VERSION_NUMBER</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>OPENSSL_VERSION_TEXT</constant>
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.snmp">snmp</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<constant>SNMP_OID_OUTPUT_FULL</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SNMP_OID_OUTPUT_NUMERIC</constant>
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.sem">Semaphore</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<constant>MSG_EAGAIN</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>MSG_ENOMSG</constant>
</simpara>
</listitem>
</itemizedlist>
</section>
<section xml:id="migration52.class-constants">
<title>New Class Constants</title>
<para><link linkend="intro.pdo">pdo</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<constant>PDO::ATTR_DEFAULT_FETCH_MODE</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>PDO::FETCH_PROPS_LATE</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>PDO::FETCH_KEY_PAIR</constant>
</simpara>
<simpara>
Fetches a 2 column result set into an associated array. (Added in PHP 5.2.3)
</simpara>
</listitem>
</itemizedlist>
<para><link linkend="ref.spl">spl</link>:</para>
<itemizedlist>
<listitem>
<simpara>
<constant>CachingIterator::FULL_CACHE</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CachingIterator::TOSTRING_USE_INNER</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SplFileObject::READ_AHEAD</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SplFileObject::READ_CSV</constant>
</simpara>
</listitem>
<listitem>
<simpara>
<constant>SplFileObject::SKIP_EMPTY</constant>
</simpara>
</listitem>
</itemizedlist>
</section>
<section xml:id="migration52.newconf">
<title>New INI Configuration Directives</title>
<para>
New &php.ini; directives introduced in PHP 5.2.0:
</para>
<itemizedlist>
<listitem>
<simpara>
<link linkend="ini.allow-url-include">allow_url_include</link>
</simpara>
<simpara>
This useful option makes it possible to differentiate between
standard file operations on remote files, and the inclusion of
remote files. While the former is usually desirable, the latter can
be a security risk if used naively. Starting with PHP 5.2.0, you can
allow remote file operations while disallowing the inclusion of
remote files in local scripts. In fact, this is the default
configuration.
</simpara>
</listitem>
<listitem>
<simpara>
<link linkend="ini.pcre.backtrack-limit">pcre.backtrack_limit</link>
</simpara>
<simpara>
PCRE's backtracking limit.
</simpara>
</listitem>
<listitem>
<simpara>
<link linkend="ini.pcre.recursion-limit">pcre.recursion_limit</link>
</simpara>
<simpara>
PCRE's recursion limit. Please note that if you set this value to a high
number you may consume all the available process stack and eventually
crash PHP (due to reaching the stack size limit imposed by the Operating
System).
</simpara>
</listitem>
<listitem>
<simpara>
<link linkend="ini.session.cookie-httponly">session.cookie_httponly</link>
</simpara>
<simpara>
Marks the cookie as accessible only through the HTTP protocol. This means
that the cookie won't be accessible by scripting languages, such as
JavaScript. This setting can effectively help to reduce identity theft
through XSS attacks (although it is not supported by all browsers).
</simpara>
</listitem>
</itemizedlist>
<para>
New directives in PHP 5.2.2:
</para>
<itemizedlist>
<listitem>
<simpara>
<link linkend="ini.max-input-nesting-level">max_input_nesting_level</link>
</simpara>
<simpara>
Limits how deep <link linkend="language.variables.external">input
variables</link> can be nested, default is 64.
</simpara>
</listitem>
</itemizedlist>
</section>
<section xml:id="migration52.errorrep">
<title>Error Reporting</title>
<para>
Some of the existing <constant>E_ERROR</constant> conditions have been
converted to something that can be caught with a user-defined error
handler. If an <link
linkend="errorfunc.constants"><constant>E_RECOVERABLE_ERROR</constant></link>
is not handled, it will behave in the same way as
<constant>E_ERROR</constant> behaves in all versions of PHP. Errors of
this type are logged as <literal>Catchable fatal error</literal>.
</para>
<para>
This change means that the value of the <constant>E_ALL</constant>
<link linkend="ini.error-reporting">error_reporting</link> constant is
now 6143, where the previous value was 2047. Because PHP constants have
no meaning outside of PHP, in some cases the integer value is used
instead so these will need to be adjusted. So for example by
setting the error_reporting mode from either the
<link linkend="apache.configuration">httpd.conf</link> or the
<filename>.htaccess</filename> files, the value has to be changed
accordingly. The same applies when the numeric values are used
rather than the constants in PHP scripts.
</para>
<para>
As a side-effect of a change made to prevent duplicate error messages when
<link linkend="ini.track-errors">track_errors</link> is
<literal>On</literal>, it is now necessary to return &false; from
user defined error handlers in order to populate
<varname>$php_errormsg</varname>. This
provides a fine-grain control over the levels of messages stored.
</para>
</section>
<section xml:id="migration52.other">
<title>Other Enhancements</title>
<itemizedlist>
<listitem>
<simpara>
Improved memory manager and increased default memory limit.
</simpara>
<simpara>
The new memory manager allocates less memory and works faster than the
previous incarnation. It allocates memory from the system in large blocks,
and then manages the heap by itself. The <literal>memory_limit</literal> value in &php.ini; is
checked, not for each <literal>emalloc()</literal> call (as before), but for actual blocks
requested from the system. This means that <literal>memory_limit</literal> is far more
accurate than it used to be, since the old memory manager didn't calculate
all the memory overhead used by the <literal>malloc</literal> library.
</simpara>
<simpara>
Thanks to this new-found accuracy memory usage may appear to have increased,
although actually it has not. To accommodate this apparent increase, the
default <literal>memory_limit</literal> setting was also increased - from 8 to 16 megabytes.
</simpara>
</listitem>
<listitem>
<simpara>
Added support for constructors in interfaces to force constructor signature
checks in implementations.
</simpara>
<simpara>
Starting with PHP 5.2.0, interfaces can have constructors. However, if you choose
to declare a constructor in an interface, each class implementing that interface
MUST include a constructor with a signature matching that of the base interface
constructor. By 'signature' we mean the parameter and return type definitions,
including any type hints and including whether the data is passed by reference
or by value.
</simpara>
</listitem>
</itemizedlist>
</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
-->
|