2

i am trying to copy a png file using the next code

$cty2 = 'filename';
fwrite($fh, $stringData);
$old = 'images/bg_freeze.png';
$new = 'images/$cty2.png';
copy($old, $new) or die("Unable to copy $old to $new.");
fclose($fh);

But, the result is a png file with this name ( $cty2.png ) it should be ( filename.png )

How I solve it to make the new file name ( filename.png ) not ( $cty2.png )

2
  • Please add the relevant language tag to your question. Commented May 22, 2012 at 23:37
  • I have edited as Perl-related (jumped the gun :-/), please correct if in error. Commented May 23, 2012 at 0:02

1 Answer 1

11

You haven't specified which language. But the problem is almost certainly that you need to use double-quotes ("), not single-quotes ('). Otherwise variables will not be expanded inside the string.

Sign up to request clarification or add additional context in comments.

1 Comment

$old = "images/bg_freeze.png"; $new = "images/$cty2.png";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.