Jump to content

Script stops working when substitue variable for constant


ghurty

Recommended Posts

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

 

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.