foreach($class as $key => $value) {
print "$key => $value
";
}
<?php
class MyClass
{
public $var1 = 'value 1';
public $var2 = 'value 2';
public $var3 = 'value 3';
protected $protected = 'protected var';
private $private = 'private var';
function iterateVisible() {
echo "MyClass::iterateVisible:
";
foreach ($this as $key => $value) {
print "$key => $value
";
}
}
}
$class = new MyClass();
foreach($class as $key => $value) {
print "$key => $value
";
}
echo "
";
$class->iterateVisible();
?>
foreach ($obj as $key => $value) {
echo "$value
";
}
foreach ($obj as $key => $value) {
echo "$key => $value
";
//echo "test greper";
}
foreach ($obj as $key => $value) {
echo "$key => $value
";
}
foreach ($objects as $obj){
echo $obj->user->description;
}
PHP By Wandering Weevil on Mar 8 2020
$person = new StdClass();
$person->name = "Ngbokoli";
$person->age = 31;
$person->nationnality = "Congolese";
$person->profession = "Student";
foreach ($person as $key => $value) {
echo $key." ".$value."
";
}
foreach ($objects as $obj) {
echo $obj->property;
}
<?php
class MyClass
{
public $var1 = 'valeur 1';
public $var2 = 'valeur 2';
public $var3 = 'valeur 3';
protected $protected = 'variable protégée';
private $private = 'variable privée';
function iterateVisible() {
echo "MyClass::iterateVisible:
";
foreach ($this as $key => $value) {
print "$key => $value
";
}
}
}
$class = new MyClass();
foreach($class as $key => $value) {
print "$key => $value
";
}
echo "
";
$class->iterateVisible();
// Try edit message
const data = {
message: 'Hello world',
}
$('#msg').html(data.message)
console.log(data)