php object
//create a person object in PHP
$person=new stdClass();
$person->firstName="Chuck";
$person->lastName="Bartowski";
$person->age=27;
print_r($person);
php object
//create a person object in PHP
$person=new stdClass();
$person->firstName="Chuck";
$person->lastName="Bartowski";
$person->age=27;
print_r($person);
create a class in php
<?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();
?>
object php
//object init
$object = (object) [
'propertyOne' => 'foo',
'propertyTwo' => 42,
];
php object
$o= new \stdClass();
$o->a = 'new object';
OR
$o = (object) ['a' => 'new object'];
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us