×
Clear all filters including search bar
Valeri Tandilashvili's Personal Professional Blog
interface IMusician {
public function play();
}
class Guitarist implements IMusician {
public function play() {
echo "playin a guitar";
}
}
In this example Guitarist
child class has to define play()
method because the child class implements interface IMusician
that has the method signature.logout
item will grow twice as quick as .home
item.home {
flex-grow: 1;
}
.logout{
flex-grow: 2;
}
p::first-letter {
color: blue;
font-size: 20px;
font-weight: bold;
background-color: yellow;
}
json_decode
returns an instance of stdClass
class$json = '{ "foo": "bar", "number": 42 }';
$stdInstance = json_decode($json);
//Example with StdClass
echo get_class($stdInstance) . ':' . PHP_EOL;
echo $stdInstance->foo . PHP_EOL; //"bar"
echo $stdInstance->number . PHP_EOL . PHP_EOL;
//Example with associative array
echo 'associative array:' . PHP_EOL;
$array = json_decode($json, true);
echo $array['foo'] . PHP_EOL; //"bar"
echo $array['number'] . PHP_EOL; //42
2. Casting an array to an object returns an instance of stdClass
class$array = array(
'Property1'=>'hello',
'Property2'=>'world',
'Property3'=>'again',
);
$obj = (object) $array;
echo get_class($obj) . ':' . PHP_EOL;
echo $obj->Property3;
User details info represented using an array and an object$array_user = array();
$array_user["name"] = "smith john";
$array_user["username"] = "smith";
$array_user["id"] = "1002";
$array_user["email"] = "smith@nomail.com";
$obj_user = new stdClass;
$obj_user->name = "smith john";
$obj_user->username = "smith";
$obj_user->id = "1002";
$obj_user->email = "smith@nomail.com";
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$this->addError('email', 'email must be a valid email');
}
p::first-line {
color: blue;
font-size: 20px;
font-weight: bold;
background-color: yellow;
}
.my-form input[type="text"]{
padding: 8px;
width: 100%;
}
In this example, only inputs will be selected with types text
<div class="container">
<div class="row">
<div class="col-sm">
One of three columns
</div>
<div class="col-sm">
One of three columns
</div>
<div class="col-sm">
One of three columns
</div>
</div>
</div>
class BaseClass {
function __construct() {
print "In BaseClass constructor\n";
}
}
class SubClass extends BaseClass {
function __construct() {
parent::__construct();
print "In SubClass constructor\n";
}
}
class OtherSubClass extends BaseClass {
// inherits BaseClass's constructor
}
// In BaseClass constructor
$obj = new BaseClass();
// In BaseClass constructor
// In SubClass constructor
$obj = new SubClass();
// In BaseClass constructor
$obj = new OtherSubClass();