Skip to content

Instantly share code, notes, and snippets.

@tlkshadow
Last active January 5, 2020 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlkshadow/6f214caddd8aec86c95136366005cf83 to your computer and use it in GitHub Desktop.
Save tlkshadow/6f214caddd8aec86c95136366005cf83 to your computer and use it in GitHub Desktop.
<?php
$data = ['likes' => 'Laravel'];
$object = new stdClass();
$object->name = 'Marcel';
$object->city = 'Hamburg';
if (property_exists($object, 'name')) {
echo $object->name;
}
echo ' from ';
if (property_exists($object, 'city')) {
echo $object->city;
}
echo ' likes ';
if (array_key_exists('likes', $data)) {
echo $data['likes'];
}
if (!empty($data['not'])) {
echo $data['not'];
} else {
echo '!';
}
# Marcel from Hamburg likes Laravel!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment