Hi.

in open source package moodle i came across "global $CFG" line of code in setup.php

in config it is used as

$CFG->dbtype    = 'mysql';
$CFG->dbhost    = 'localhost';
 ............

$CFG is global object but there is no class. it is behaving like an array.
how there can be object without class? please put some light. this is my first encouter with this type of code.

is it just another kind of array?

thanks

Recommended Answers

All 2 Replies

There is a default PHP class/object called stdClass. When you define variables this way without first defining a class, it will make them part of stdClass.

Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.