Глава 14: существование метода

This commit is contained in:
Igor Simdyanov
2022-05-02 11:59:30 +03:00
parent 9f2325e800
commit 9f724eb725
5 changed files with 38 additions and 0 deletions

10
classes/dump.php Normal file
View 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>';

View 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
View File

@ -0,0 +1,6 @@
<?php
require_once 'point.php';
$point = new Point;
// Такого метода в объекте нет
echo $point->say('PHP');

8
methods/methods_list.php Normal file
View File

@ -0,0 +1,8 @@
<?php
require_once 'point.php';
$point = new Point;
echo '<pre>';
print_r(get_class_methods($point));
echo '</pre>';

View File

@ -0,0 +1,6 @@
<?php
require_once 'greeting.php';
$greeting = new Greeting;
echo $greeting->x;