Ramanvir Sodhi
Ramanvir Sodhi

Reputation: 161

temporarily store remote images to server

copy('https://graph.facebook.com/$fbid/picture?type=large', 'images/$fbid.jpg');

i am using the above code to store the image locally ..

the above code works without the variable. As it does not executes php in it so it is useless with links containing php variables....

The code works with a definite url is provided... i wanna use the above url of source and destination respectively to get image... please suggest me any other workaround or way that allows the links with variables to be executed ....

Upvotes: 1

Views: 422

Answers (1)

slugonamission
slugonamission

Reputation: 9642

Your strings are wrapped in ' ', to use variable interpolation, you need to wrap yours strings in " ", so copy("https://graph.facebook.com/$fbid/picture?type=large", "images/$fbid.jpg"); will work.

Also, to make it clearer, it's possible to wrap your variables in { }, so "Hello {$world}" will, assuming $world contains "World", print "Hello World".

There's a few other gotchas, so have a look over the PHP manual page for strings I've put at the bottom of this post.

Ref: http://php.net/manual/en/language.types.string.php

Upvotes: 2

Related Questions