Skip to content

Commit

Permalink
Update objects.php
Browse files Browse the repository at this point in the history
  • Loading branch information
gsingh0101 authored Feb 28, 2024
1 parent 8cdc843 commit b46cfd9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions php-concepts/objects.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?php

// mainly about the default stdclass objects
// more object examples also covered in classes.php file

echo '<pre/>';


$o = new stdclass();
$o->a = 1;
$o->b = 2;

echo '<pre/>';
//print_r($o);

print_r($o);
echo '<br/>';

$a = [1, 2];
$acasttoObject = (object)$a;
Expand All @@ -17,3 +22,8 @@
// below command disabled on online testing sites
// echo get_class($acasttoObject);

unset($o->a); // removes one of the members of the class, not possible in c language

print_r($o);
echo '<br/>';

0 comments on commit b46cfd9

Please sign in to comment.