Classes (PHP): verschil tussen versies
Naar navigatie springen
Naar zoeken springen
Regel 1: | Regel 1: | ||
− | == | + | == Example == |
<pre> | <pre> | ||
Regel 36: | Regel 36: | ||
== Get methods == | == Get methods == | ||
− | + | Example <code>get_class_methods</code> [https://www.php.net/manual/en/function.get-class-methods.php]: | |
<pre> | <pre> | ||
Regel 56: | Regel 56: | ||
</pre> | </pre> | ||
− | == | + | == See also == |
* [[Arrays (PHP)]] | * [[Arrays (PHP)]] | ||
− | == | + | == Sources == |
* https://www.php.net/manual/en/language.oop5.references.php | * https://www.php.net/manual/en/language.oop5.references.php |
Versie van 3 nov 2023 10:44
Example
<?php # ################################################################### # # Define class "A" ################## # class A { # Declare proptery & assign value ################################## # public $foo = 1; } # Instantiate object class A ############################ # $a = new A; # Print propery $foo #################### # echo $a -> foo."\n"; # Manipulate $foo #################### # $a->foo = 12; echo $a -> foo."\n";
Get methods
Example get_class_methods
[1]:
$sql="show databases;"; $result = $conn->query($sql); print_r(get_class_methods($conn));
Get properties
Voorbeeld get_objects_vars
[2]:
sql="show databases;"; $result = $conn->query($sql); print_r(get_object_vars($conn));