PHP: definition conflict

Self-tutoring about “importing” artefacts in PHP: the tutor begins…

In PHP, you can bring code from other files using, among other methods,

require_once(‘a_file’);

What if you end up using require_once multiple times to bring in different libraries, but two happen to contain their own definitions of a same-named artefact?

I thought the last definition to arrive would overwrite any other, like in CSS. However, when I tried it, the program wouldn’t run at all; the server refused to serve it.

One can imagine that two large, hastily assembled libraries by separate members of a team might end up containing their own definitions for a class of the same name. Yet, perhaps, a file that requires both those libraries mayn’t run.

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Leave a Reply