Jump to content

define help...


eric1235711

Recommended Posts

Huh! With the following code:
[code=php:0]define('TEST', 'test is' . ($test? ' ': ' not ') . 'ok');
echo TEST;[/code]

PHP will define TEST as "test is ok" if the variable $test exists or holds a boolean that is true, is a string or a number etc. If $test was set to a boolean that is false, null or not a string/number etc it'll define TEST as "test is not ok".

When ever you initiate define('VAR_NAME', blah blah) PHP will define the constant VAR_NAME with whats in the secound parameter.

If you have ten files that has 100 defines it will only define 100 constants at a time as you can only run one file at a time, unless you include the other 9 files.
Link to comment
https://forums.phpfreaks.com/topic/20862-define-help/#findComment-92510
Share on other sites

Here where I´m working there are is a single functions file called 'general.php' with more than 9000 lines. It also includes other function files...  Lips sealed

There are almost all the functions (not general functions are there too)...

won´t it overcharge the server or will it not do a lot of useless processing? And won´t it put a lot of trash in the server´s memory?
Link to comment
https://forums.phpfreaks.com/topic/20862-define-help/#findComment-92536
Share on other sites

Not really no as PHP doesnt load the pages into memery. It just parses php code in the php files. Whne its done parsing the script it releases any memory being used back to the system, this is why variables/constants only work on the file they where created on. PHP only runs on a per-request basis, meaning it'll only run when a client (web browser) request the server for the desiered PHP file.
Link to comment
https://forums.phpfreaks.com/topic/20862-define-help/#findComment-92539
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.