0
Good people, I want to use the method_exist()
, I’m trying to pass values to my class in PHP
, in URL
that need to call the class it is necessary to call the method to where the values go.
How’s a file to handle it ?
0
Good people, I want to use the method_exist()
, I’m trying to pass values to my class in PHP
, in URL
that need to call the class it is necessary to call the method to where the values go.
How’s a file to handle it ?
2
I didn’t quite understand the question, but here’s what function is and how to use it.
The function method_exists() only checks if a method exists:
Description:
bool method_exists ( object $object , string $method_name )
true
whether the method has been found and false
if not);Definition:
if(method_exists('MinhaClasse','MeuMetodo')) {
echo "existe";
} else {
echo "não existe";
}
Example:
<?php
$directory = new Directory('.');
var_dump(method_exists($directory,'read')); //retorna true pois existe o método read na classe de diretório
?>
The same can see done so:
<?php
var_dump(method_exists('Directory','read'));
?>
Example:
<?php
class A {
public function FUNC() {
echo '*****';
}
}
$a = new A();
$a->func(); // printa *****
var_dump(method_exists($a, 'func')); // retorna bool(true) pois existe tal método
?>
See more: PHP documentation: method_exists()
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.
Thanks for that summary, it helped a lot !
– Pedro Soares