Undocumented stuff
Feel free to document anything presented here. Entries linking to user notes have not been confirmed, so may or may not need documentations (or demonstrate real bugs) but they are worth exploring.
PHP 6
<?php
$unicode = '傀傂两亨乄了乆刄';
$binary = b'傀傂两亨乄了乆刄';
$binary2 = (binary) $unicode;
$binary3 = b<<<FOO
傀傂两亨乄了乆刄
FOO;
echo strlen($unicode);
echo strlen($binary);
echo strlen($binary2);
echo strlen($binary3);
?>
<?php
// '\Uxxxxxx'
$str = 'U+123: \U000123';
// '\uxxxx'
$str = 'U+123: \u0123';
// unicode(8) "U+123: ģ"
var_dump($str);
?>
<?php
$GLOBALS["\u212B"] = ' 승인 ';
// U+00C5 = Å
echo $GLOBALS["\u00C5"];
?>
PHP 5.3
SPL classes: ArrayObject, CachingIterator, RecursiveCachingIterator, DirectoryIterator, FilterIterator, LimitIterator, ParentIterator, RecursiveDirectoryIterator, RecursiveIteratorIterator, SimpleXMLIterator
<?php
class bar {
public function show() {
var_dump(new static);
}
}
class foo extends bar {
public function test() {
parent::show();
}
}
$foo = new foo;
$foo->test();
$foo::test();
/*
object(foo)#2 (0) {
}
object(bar)#2 (0) {
}
*/
?>
<?php
class foo { }
class_alias('foo', 'bar');
var_dump(new bar);
/*
object(foo)#1 (0) {
}
*/
?>
<?php
print <<<"FOO"
Foobar! :)
FOO;
?>
user_ini.filename and user_ini.cache_ttl.
PHP 5.x
<?php
interface iTest { }
class baz implements iTest {}
class bar { }
class foo extends bar {
public function testFoo(self $obj) {
var_dump($obj);
}
public function testBar(parent $obj) {
var_dump($obj);
}
public function testBaz(iTest $obj) {
var_dump($obj);
}
}
$foo = new foo;
$foo->testFoo(new foo);
$foo->testBar(new bar);
$foo->testBaz(new baz);
$foo->testFoo(new stdClass); // Catchable fatal error
?>
<?php
$foo = new stdClass;
$foo->{'foo-bar'} = 'foo!';
var_dump($foo);
/*
object(stdClass)#1 (1) {
["foo-bar"]=>
string(4) "foo!"
}
*/
?>
Others
Trick for access private properties. (
Article)
<?php
class foo {
private $bar = 42;
}
$obj = new foo;
$propname="\0foo\0bar";
$a = (array) $obj;
echo $a[$propname];
?>
<?php
class ToString
{
public function __toString()
{
return "1337";
}
}
var_dump((int) (string) new ToString);
?>
<?php
class Test
{
private $test;
}
var_dump((object) (array) new Test);
?>
<?php
function test(&$var) { }
$arr = array();
test($arr[]);
?>
Add example
Add Reference
mb_ereg_search_init
- Missing list of options. (
php-src/ext/mbstring/oniguruma/doc/API)
User Requests
fileinfo.installation: “How to install fileinfo on Win32 (and Linux for that matter” (
note)
Windows: There is a related TODO item
here
mysqli-autocommit: “autocommit not only turns on/off transactions, but will also 'commit' any waiting queries.” (
note)
mysqli-report: “are sent through an exception named 'mysqli_sql_exception' instead of a normal PHP warning.” (
note)
pdf-begin-document: “doesn't seem to be much documentation on setting options with this function, ... some basic things:” (
note)
function.curl-init: “has undefined behavior if you pass 'false'” (
note)
function.dio-stat: “This extension is only available on Windows Platforms as of PHP 5.0.0” (
note)
ref.pdo:
Example#5: “We must change the last two lines to catch the error ...” (
note)
function.xmlwriter-write-element: “The second argument ($content) is actually not optional...” (
note)
function.get-cfg-var: “It seems that this function doesn't work on Unix Operating Systems.” (
note)
function.socket-read: “On non-blocking connections it may not return full length requested.” (
note)
function.imagickdraw-setfillalpha: “setFillAlpha is deprecated use the replacement: setFillOpacity” (
note)
function.disk-free-space: “Note that disk_free_space() does an open_basedir check.” (
note)
function.imagick-trimimage: “This method requires ImageMagick version >= 6.2.8” (
note)
ref.soap: “Do NOT use associative arrays or arrays not starting with element number 0...” (
note)
migration5.incompatible: “As with array_merge(), array_merge_recursive() returns NULL in PHP 5 if a non-array parameter is passed to it.” (
note)
function.version-compare: “It should be noted that version_compare() considers 1 < 1.0 < 1.0.0 etc.” (
note)
function.ftp-nlist: You can do a wildcard file listing with ftp_nlist (
note)
function.ftp-rawlist: the second parameter accepts also standard arguments of /bin/ls command like “-l” or “-t” (
note)
function.curl-getinfo: “There is a constant missing from that list. CURLINFO_REDIRECT_COUNT will give you the number of redirects it went through if CURLOPT_FOLLOWLOCATION was set.” (
note)
function.shell-exec: “If the return is empty, then command could not be executed or executed command returned an error.” (
note)
tokens: “Undocumented constants/syntax/reference” (
note)
function.dns-get-record: “Note that if you check a non-existing domain you will get ...” (
note)
arrayobject.offsetset: “If $index is null, $newval is naturally pushed onto the end of the array as ArrayObject::append” (
note)
mysqli.prepare: “All data must be fetched before a new statement prepare” (
note)
function.imagesetthickness: “Apparently imagesetthickness doesn't work if antialiasing is set to true.” (
note)
function.session: “if you try to name a php session “example.com” it gets converted to “example_com” and everything breaks.” (
note)
Internals