Skip to content
Advertisement

What is the meaning of the asterisk before an array key name in print_r

When using print_r($myArray, true) for one of my arrays I get:

Array
(
     [id] => 14
     [name] => My Name
     [*createdAt] => CarbonCarbon Object
         (
             [date] => 2020-03-18 10:00:26.000000
             [timezone_type] => 3
             [timezone] => UTC
         )

     [*updatedAt] => CarbonCarbon Object
         (
             [date] => 2020-08-26 10:10:10.000000
             [timezone_type] => 3
             [timezone] => UTC
         )
)

What is the meaning of the asterisk in [*createdAt] and [*updatedAt]?

Also, I cannot access these fields. How can I access them?

Advertisement

Answer

The asterisk indicates an Object. And it is protected. This is the reason why you can’t access them.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement