eric1235711 Posted September 15, 2006 Share Posted September 15, 2006 This works?[code]<?phpif ($test) define('TEST', 'test is ok');else define('TEST', 'test is not ok');echo TEST;?>[/code]of course I will not do some like it, but I just want to know if using define inside a 'if' clause works... ??? Quote Link to comment https://forums.phpfreaks.com/topic/20862-define-help/ Share on other sites More sharing options...
eric1235711 Posted September 15, 2006 Author Share Posted September 15, 2006 i need to do me thing like this?[code]<?phpdefine('TEST', 'test is' . ($test? ' ': ' not ') . 'ok');echo TEST;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20862-define-help/#findComment-92386 Share on other sites More sharing options...
wildteen88 Posted September 15, 2006 Share Posted September 15, 2006 Why dont you try it out for yourself then you'll know. It works for me I get "[i]test is not ok[/i]" message. Quote Link to comment https://forums.phpfreaks.com/topic/20862-define-help/#findComment-92387 Share on other sites More sharing options...
eric1235711 Posted September 15, 2006 Author Share Posted September 15, 2006 I´d like to know if php reads all the defines I´ve declared and builds a table with the constants...If I make ten files with a hundred defines in each, php will build a table with a thousand constants? Quote Link to comment https://forums.phpfreaks.com/topic/20862-define-help/#findComment-92390 Share on other sites More sharing options...
eric1235711 Posted September 15, 2006 Author Share Posted September 15, 2006 help... Quote Link to comment https://forums.phpfreaks.com/topic/20862-define-help/#findComment-92475 Share on other sites More sharing options...
wildteen88 Posted September 15, 2006 Share Posted September 15, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/20862-define-help/#findComment-92510 Share on other sites More sharing options...
eric1235711 Posted September 15, 2006 Author Share Posted September 15, 2006 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 sealedThere 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? Quote Link to comment https://forums.phpfreaks.com/topic/20862-define-help/#findComment-92536 Share on other sites More sharing options...
wildteen88 Posted September 15, 2006 Share Posted September 15, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/20862-define-help/#findComment-92539 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.