ghurty Posted January 25, 2010 Share Posted January 25, 2010 I have the following script that works perfectly. The problem is when I substitute a variable it stops working: #!/usr/bin/php -q <?php $origdirectory= '/temp/0125/; $destdirectory='/destination/'; if(is_dir($origdirectory)) { $dh=opendir($origdirectory); $ctr=0; while($ctr<15 && $file=readdir($dh)) { if(is_file($origdirectory.$file)) { rename($origdirectory.$file,$destdirectory.$file); $ctr++; } } closedir($dh); if(!$ctr) rmdir($origdirectory); } ?> But when I try to change to: $temp = date(md); $origdirectory= '/temp/$temp/'; It stops working. I am using 0125 in this example, because it is todays date. Thanks Quote Link to comment Share on other sites More sharing options...
jl5501 Posted January 25, 2010 Share Posted January 25, 2010 variables are not evaluated inside single quotes. Try $origdirectory= "/temp/$temp/"; Quote Link to comment Share on other sites More sharing options...
ghurty Posted January 25, 2010 Author Share Posted January 25, 2010 It worked. Thanks Quote Link to comment 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.