mirror of
https://github.com/igorsimdyanov/php8.git
synced 2025-07-29 12:52:43 +00:00
Глава 14: существование метода
This commit is contained in:
10
classes/dump.php
Normal file
10
classes/dump.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
require 'point.php';
|
||||
|
||||
$point = new Point;
|
||||
$point->x = 3;
|
||||
$point->y = 7;
|
||||
|
||||
echo '<pre>';
|
||||
print_r($point);
|
||||
echo '</pre>';
|
8
methods/method_exists.php
Normal file
8
methods/method_exists.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
require_once 'point.php';
|
||||
|
||||
$point = new Point;
|
||||
|
||||
if (method_exists($point, 'say')) {
|
||||
echo $point->say('PHP');
|
||||
}
|
6
methods/method_wrong.php
Normal file
6
methods/method_wrong.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
require_once 'point.php';
|
||||
|
||||
$point = new Point;
|
||||
// Такого метода в объекте нет
|
||||
echo $point->say('PHP');
|
8
methods/methods_list.php
Normal file
8
methods/methods_list.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
require_once 'point.php';
|
||||
|
||||
$point = new Point;
|
||||
|
||||
echo '<pre>';
|
||||
print_r(get_class_methods($point));
|
||||
echo '</pre>';
|
6
methods/property_wrong.php
Normal file
6
methods/property_wrong.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
require_once 'greeting.php';
|
||||
|
||||
$greeting = new Greeting;
|
||||
|
||||
echo $greeting->x;
|
Reference in New Issue
Block a user