Forum Moderators: coopster

Message Too Old, No Replies

OOP in command line PHP

         

hawkerz

2:28 pm on Jul 11, 2007 (gmt 0)

10+ Year Member



I'm trying to write a fairly simple, easy to reconfigure php script which must be run from the command line, in this case, of a windows machine. I am defining my variables in a file called 'config.php' and i am requiring config.php at the top of the script (first thing i do). When i go to execute the script from the command line, it simply echos the contents of config.php in the command prompt. How do I fix this?

eelixduppy

2:49 pm on Jul 11, 2007 (gmt 0)



How are you executing the script? IT must be read by the php interpreter to be 'executed'.

hawkerz

2:52 pm on Jul 11, 2007 (gmt 0)

10+ Year Member



just using

$require_once('config.php');

and instead it prints the contents of config.php...

C:\Inetpub\wwwroot\gcs>php index_page_generator.php
// DO NOT TOUCH THIS LINE
$letters = array("a","b","c","d","e", "f", "g", "h", "i", "j", "k", "l", "m", "n
", "o", "p", "q", "r", "s", "t", "u","v", "w", "x", "y", "z", "1", "2", "3", "4"
, "5", "6", "7", "8", "9");

// The number of files to use to get part numbers from
$num_files = "6";

... etc etc etc
PHP Notice: Undefined variable: num_files in C:\Inetpub\wwwroot\gcs\index_page_
generator.php on line 8

hawkerz

2:54 pm on Jul 11, 2007 (gmt 0)

10+ Year Member



nevermind, issue resolved. Forgot to put <?php?> inside the config :)

eelixduppy

3:17 pm on Jul 11, 2007 (gmt 0)



hehe - that will do it. glad you got it :)