drifter Posted February 13, 2007 Share Posted February 13, 2007 I have an open source app that I run that does a lot of data processing. The problem is that I need to run this thing a total of 8 times with different variables. I was just going to write a program and say include(); whenever I needed it. THe problem is looking at it, it uses lots of defined constants... since these are global scope and can not be changed, I will not be able to run it a second time and change the variables. So is there any way to isolate this extra script in a class or something that will limit the scope of the define. I could put eight cron jobs in, but I would rather them run sequentially since I have no idea how long they will take to run at any given time. Is there a way I can right a shell or something that will run one php script and when that is done run the next? Thanks Scott Link to comment https://forums.phpfreaks.com/topic/38258-constants-and-scope/ Share on other sites More sharing options...
redarrow Posted February 13, 2007 Share Posted February 13, 2007 Here you go i have defined the price of $10.000 in a function then i have defined names to varables, then used those varables within functions, then you get to see the echoed information by the hour. <?php $member1="john"; $member2="paul"; $member3="toni"; $member5="petter"; $time_now=date("h"); function word(){ define("X","\$10.000"); echo X; } if($time_now=="01"){ function a($member1){ echo " $member1 you owe us ".word()." "; } echo a($member1); } if($time_now=="02"){ function b($member2){ echo " $member2 you owe us ".word()." "; } echo b($member2); } if($time_now=="03"){ function c($member3){ echo " $member3 you owe us ".word()." "; } echo a($member3); } if($time_now=="04"){ function d($member4){ echo " $member4 you owe us ".word()." "; } echo d($member4); } if($time_now=="05"){ function e($member5){ echo " $member5 you owe us ".word()." "; } echo $e($member5); } if($time_now=="06"){ function f($member1){ echo " $member1 you owe us ".word()." "; } echo f($member1); } if($time_now=="07"){ function g($member2){ echo " $member2 you owe us ".word()." "; } echo g($member2); } if($time_now=="08"){ function h($member3){ echo " $member3 you owe us ".word()." "; } echo h($member3); } if($time_now=="09"){ function i($member4){ echo " $member4 you owe us ".word()." "; } echo i($member4); } if($time_now=="10"){ function j($member5){ echo " $member5 you owe us ".word()." "; } echo $j($member5); } if($time_now=="11"){ function k($member4){ echo " $member4 you owe us ".word()." "; } echo k($member4); } if($time_now=="12"){ function l($member5){ echo " $member5 you owe us ".word()." "; } echo $l($member5); } ?> Link to comment https://forums.phpfreaks.com/topic/38258-constants-and-scope/#findComment-183325 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.