Jump to content

constant include


chokk

Recommended Posts

Hey all,I'm having a look at the framework for the free CMS "WebsiteBaker". I've stumbled across a line of code I would like to have explained.

require_once(WB_PATH."/include/phplib/template.inc");

Does this mean it's only requesting the constant WB_PATH from the template.inc file? And why is the concatenation operator used in this context?

Link to comment
Share on other sites

I've never used that CMS, but the ones I have used generally create a directory tree where important files are nested pretty deeply. I would assume that WB_PATH is a string containing the path to a central directory that contains whatever it considers important directories, such as the include directory.

Link to comment
Share on other sites

I know that WB_PATH is the path to the directory. What I'm interested in is this line as a whole.

require_once(WB_PATH."/include/phplib/template.inc");

What exactly does it do? Does it ONLY request a single constant from the entire file or?

Link to comment
Share on other sites

If you're using a CMS, this leads me to believe that WB_PATH is a constant that's set in the CMS' configuration file. It's not requesting that constant from the template file.The concatenation operator is used because everything inside quotation marks is taken literally.For example, let's pretend that WB_PATH is "http://www.yousite.com/cms".

require_once(WB_PATH."/include/phplib/template.inc");

This will get you "http://www.yousite.com/cms/include/phplib/template.inc", which is what you want. However, look at this:

require_once("WB_PATH/include/phplib/template.inc");

This will get you "WB_PATH/include/phplib/template.inc", which is what you DO NOT want.

Link to comment
Share on other sites

Ah that's so obvious! Sort of like how you echo a string and a variable.I thought it meant something like "look for the value of the constant WB_PATH in the file "/include/phplib/template.inc".Thanks for clearing that up!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...