mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
making sure that the provided examples actualy work (or at least do not
generate no parse errors) unless they are really expected to fail
This commit is contained in:
parent
1526710ce1
commit
92f355d733
2 changed files with 10 additions and 8 deletions
|
@ -56,10 +56,10 @@
|
||||||
8. Classes must be declared before used:
|
8. Classes must be declared before used:
|
||||||
<?php
|
<?php
|
||||||
$test = new fubar();
|
$test = new fubar();
|
||||||
$test->echo();
|
$test->barfu();
|
||||||
|
|
||||||
class fubar {
|
class fubar {
|
||||||
function echo() {
|
function barfu() {
|
||||||
echo 'fubar';
|
echo 'fubar';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -537,7 +537,7 @@ Changes in the Zend Engine 2.0
|
||||||
code would look something like shown below. The comments show the
|
code would look something like shown below. The comments show the
|
||||||
meaning of each proerty and hence there getter methods. As the code
|
meaning of each proerty and hence there getter methods. As the code
|
||||||
shows it is possible to read any available information by using the
|
shows it is possible to read any available information by using the
|
||||||
getter methods. But since some og the methods are used internally
|
getter methods. But since some of the methods are used internally
|
||||||
they are marked final. All in all the class is very restrictive
|
they are marked final. All in all the class is very restrictive
|
||||||
because it must be ensured that anything used internally always
|
because it must be ensured that anything used internally always
|
||||||
works as expected.
|
works as expected.
|
||||||
|
@ -546,7 +546,7 @@ Changes in the Zend Engine 2.0
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
class Exception {
|
class Exception {
|
||||||
function __construct(string $message=NULL, int code=0) {
|
function __construct(string $message=NULL, int $code=0) {
|
||||||
if (func_num_args()) {
|
if (func_num_args()) {
|
||||||
$this->message = $message;
|
$this->message = $message;
|
||||||
}
|
}
|
||||||
|
@ -853,9 +853,9 @@ Changes in the Zend Engine 2.0
|
||||||
|
|
||||||
// matches the following 7 lines with the for directive.
|
// matches the following 7 lines with the for directive.
|
||||||
$it = $obj->getIterator();
|
$it = $obj->getIterator();
|
||||||
for($it->rewind(); $it->hasMore(); $it->next) {
|
for($it->rewind(); $it->hasMore(); $it->next()) {
|
||||||
$key = $it->current();
|
$key = $it->key();
|
||||||
$val = $it->key();
|
$val = $it->current();
|
||||||
echo "$key = $val\n";
|
echo "$key = $val\n";
|
||||||
}
|
}
|
||||||
unset($it);
|
unset($it);
|
||||||
|
@ -900,9 +900,10 @@ Changes in the Zend Engine 2.0
|
||||||
class Foo {
|
class Foo {
|
||||||
function __toString() {
|
function __toString() {
|
||||||
return "What ever";
|
return "What ever";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$obj = Foo;
|
$obj = new Foo;
|
||||||
|
|
||||||
$str = (string) $obj; // call __toString()
|
$str = (string) $obj; // call __toString()
|
||||||
|
|
||||||
|
@ -933,6 +934,7 @@ Changes in the Zend Engine 2.0
|
||||||
public $prop;
|
public $prop;
|
||||||
function Func($name) {
|
function Func($name) {
|
||||||
echo "Hello $name";
|
echo "Hello $name";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reflection_class::export('Foo');
|
reflection_class::export('Foo');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue