1// Create a new instance of MyObject into $obj
2$obj = new MyObject();
3// Set a property in the $obj object called thisProperty
4$obj->thisProperty = 'Fred';
5// Call a method of the $obj object named getProperty
6$obj->getProperty();
1$x = "abc";
2$$x = 200;
3echo $x."<br/>";
4echo $$x."<br/>";
5echo $abc;
6
7// output:
8abc
9200
10200
1if (condition)
2 code to be executed if condition is true;
3else
4 code to be executed if condition is false;
5
1// Null Coalesce Operator - $statement ?? ''
2$categoryName = $category->name ?? 'Not Available';
3
4// The above Statement is identical to this if/else statement
5if (isset($category->name)) {
6 $categoryName = $category->name;
7} else {
8 $categoryName = 'Not Available';
9}