Home » Php » wordpress – I am not understanding php expression for saving values in a variable, bellow is the line of php

wordpress – I am not understanding php expression for saving values in a variable, bellow is the line of php

Posted by: admin February 25, 2020 Leave a comment

Questions:
$copyrights = $config->get( 'template.bottom_bar.copyrights' );

I understand $copyrights is a variable that has some value but pleases someone explains me the right side of the expression

$config->get( 'template.bottom_bar.copyrights' );

what does it mean
does ‘template.bottom_bar.copyrights’ is referring to a file or anything

How to&Answers:

Some frameworks allow dot notation to access array elements.

In this case,

$config->get( 'template.bottom_bar.copyrights' );

This is probably the equivalent of something like (but not quite):

$config['template']['bottom_bar']['copyrights'];

I say not quite because, depending on your framework, you might have a template.php or a template.ini file in a config directory. This file will have an array of options. The framework will load the various config files and provide a config object/helper like you have there.

The get method usually handles unknown indexes in the array and simply returns null.