create a class in php
<?php
class Foo {
public $aMemberVar = 'aMemberVar Member Variable';
public $aFuncName = 'aMemberFunc';
function aMemberFunc() {
print 'Inside `aMemberFunc()`';
}
}
$foo = new Foo;
function getVarName()
{
return 'aFuncName';
}
print $foo->{$foo->{getVarName()}}();
<?php
class Fruit {
public $name;
public $color;
function __construct($name, $color) {
$this->name = $name;
$this->color = $color;
}
function get_name() {
return $this->name;
}
function get_color() {
return $this->color;
}
}
$apple = new Fruit("Apple", "red");
echo $apple->get_name();
echo "<br>";
echo $apple->get_color();
?>class Bike {
function Bike() {
$this->type = 'BMX';
}
}
$blackSheep = new Bike();
print $blackSheep->type;The PHP Object-Oriented Programming concepts are:
Class
Objects
Inheritance
Interface
Abstraction
Magic Methods
Also in PHP:
- cache remove laravel
- buscar palabra en cadena php
- base64decode in image php
- create new record via model in laravel
- DateTime::diff()
- check type of variable in php
- ci db query error
- check if string contains specific string php
- composer artisan
- Difference in days of two dates in php
- Impossible de trouver le paquet php-gettext
- echo getType($value)
- autocomplete new-password php
- Generate Laravel Migrations from an existing database
- Fatal error: Uncaught ReflectionException: Class config does not exist in
- date format function in php
- check if a word contains python
- clean url laravel CACHE
- check word is in string php
- array_uniqe php
- count letters in string php
- drupal 8 enable twig debug
- Adding string with number in php
- CONNECT TO MYPHP DATABASE FROM connection .php