Click here to get back home

DEFAULT_FOLDER ?

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
DEFAULT_FOLDER ? Tony B 07-11-2008
Get Chitika Premium
Posted by Tony B on July 11, 2008, 5:42 am
Please log in for more thread options
I'm trying to understand some code on a php site I'm looking at.
Each page in the site has a require('filenames.php'); statement in the
header.
filenames.php has typical entries like
define('FILE_INDEX',DEFAULT_FOLDER .'index.php');

php warns that DEFAULT_FOLDER is unknown with a message like
Use of undefined constant DEFAULT_FOLDER - assumed 'DEFAULT_FOLDER' in
filenames.php on line 2

What is DEFAULT_FOLDER ? I searched uk.php.net and couldn't find a reference
to this variable ?



Posted by Jeff on July 11, 2008, 5:57 am
Please log in for more thread options
Tony B wrote:
> I'm trying to understand some code on a php site I'm looking at.
> Each page in the site has a require('filenames.php'); statement in the
> header.
> filenames.php has typical entries like
> define('FILE_INDEX',DEFAULT_FOLDER .'index.php');
>
> php warns that DEFAULT_FOLDER is unknown with a message like
> Use of undefined constant DEFAULT_FOLDER - assumed 'DEFAULT_FOLDER' in
> filenames.php on line 2
>
> What is DEFAULT_FOLDER ? I searched uk.php.net and couldn't find a reference
> to this variable ?

Well, it is not defined, obviously. You'll need to define it the same
way as FILE_INDEX.

Check "define" in the PHP docs and "constant". The DEFAULTS_FOLDER is
a constant whose define is missing in your code.

Jeff

>
>

Posted by Tony B on July 11, 2008, 6:09 am
Please log in for more thread options
> Tony B wrote:
>> I'm trying to understand some code on a php site I'm looking at.
>> Each page in the site has a require('filenames.php'); statement in the
>> header.
>> filenames.php has typical entries like
>> define('FILE_INDEX',DEFAULT_FOLDER .'index.php');
>>
>> php warns that DEFAULT_FOLDER is unknown with a message like
>> Use of undefined constant DEFAULT_FOLDER - assumed 'DEFAULT_FOLDER' in
>> filenames.php on line 2
>>
>> What is DEFAULT_FOLDER ? I searched uk.php.net and couldn't find a
>> reference to this variable ?
>
> Well, it is not defined, obviously. You'll need to define it the same way
> as FILE_INDEX.
>
> Check "define" in the PHP docs and "constant". The DEFAULTS_FOLDER is a
> constant whose define is missing in your code.
>
> Jeff
>
I didn't write the code, but was just trying to understand it. I assumed
that default_folder must be some sort of php defined variable, which it
doesn't seem to be. I guess whoever wrote the code never used the defines
since they don't make sense. My guess is maybe DEFAULT_FOLDER is supposed to
be defined as the site root folder path as then FILE_INDEX would point to
the main home page ?
Tony



Posted by sathyashrayan on July 11, 2008, 10:01 am
Please log in for more thread options

>> Tony B wrote:
>>> I'm trying to understand some code on a php site I'm looking at.
>>> Each page in the site has a require('filenames.php'); statement in the
>>> header.
>>> filenames.php has typical entries like
>>> define('FILE_INDEX',DEFAULT_FOLDER .'index.php');
>>>
>>> php warns that DEFAULT_FOLDER is unknown with a message like
>>> Use of undefined constant DEFAULT_FOLDER - assumed 'DEFAULT_FOLDER' in
>>> filenames.php on line 2
>>>
>>> What is DEFAULT_FOLDER ? I searched uk.php.net and couldn't find a
>>> reference to this variable ?
>>
>> Well, it is not defined, obviously. You'll need to define it the same way
>> as FILE_INDEX.
>>
>> Check "define" in the PHP docs and "constant". The DEFAULTS_FOLDER is a
>> constant whose define is missing in your code.
>>
>> Jeff
>>
> I didn't write the code, but was just trying to understand it. I assumed
> that default_folder must be some sort of php defined variable, which it
> doesn't seem to be. I guess whoever wrote the code never used the defines
> since they don't make sense. My guess is maybe DEFAULT_FOLDER is supposed
> to be defined as the site root folder path as then FILE_INDEX would point
> to the main home page ?
> Tony
>

Those defines might be in a config.php or in the include folder.


>



Posted by Jeff on July 11, 2008, 10:06 am
Please log in for more thread options
Tony B wrote:
>> Tony B wrote:
>>> I'm trying to understand some code on a php site I'm looking at.
>>> Each page in the site has a require('filenames.php'); statement in the
>>> header.
>>> filenames.php has typical entries like
>>> define('FILE_INDEX',DEFAULT_FOLDER .'index.php');
>>>
>>> php warns that DEFAULT_FOLDER is unknown with a message like
>>> Use of undefined constant DEFAULT_FOLDER - assumed 'DEFAULT_FOLDER' in
>>> filenames.php on line 2
>>>
>>> What is DEFAULT_FOLDER ? I searched uk.php.net and couldn't find a
>>> reference to this variable ?
>> Well, it is not defined, obviously. You'll need to define it the same way
>> as FILE_INDEX.
>>
>> Check "define" in the PHP docs and "constant". The DEFAULTS_FOLDER is a
>> constant whose define is missing in your code.
>>
>> Jeff
>>
> I didn't write the code, but was just trying to understand it. I assumed
> that default_folder must be some sort of php defined variable, which it
> doesn't seem to be. I guess whoever wrote the code never used the defines
> since they don't make sense.

It make sense, more or less, to me. My guess is that there is an include
somewhere that is missing that has the DEFAULT_FOLDER set.

My guess is maybe DEFAULT_FOLDER is supposed to
> be defined as the site root folder path as then FILE_INDEX would point to
> the main home page ?

That would be my guess as well. Although there are times when you
don't want something to be in the web root. Hence the ability to set the
path from which all others spring forth. At least that's the way I write
my code. I keep the default settings which might change from one usage
to another in a separate file. That way if I want to use the same code
on another site, I just change one included file. Generally you really
don't want to have to go back in and change every script.

Try adding something like this:

define('DEFAULT_FOLDER',$_SERVER['DOCUMENT_ROOT'] . '/');

or use whatever path you want.

Now, I'm a php newbie myself. There's different coding styles. Some
may not mind editing the scripts themselves.

Jeff

> Tony
>
>


Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap