0

I wish to download data from a web site. The link is of the format

$homepage = file_get_contents('http://www.dataserver.com/getfeed/72062b24e00c4aa4ad7208d98c02bb39/h2h/9249/9002');

when I send this link the download is successful. However, because the two values 9249 and 9002 will be changing, I prefer to embed them in the link as variables, thus $homepage = file_get_contents('http://www.dataserver.com/getfeed/72062b24e00c4aa4ad7208d98c02bb39/h2h/$t1/$t2');

This string fails to download. My request is for help on the correct format of embedding $t1 and $t2. Thanks.

Ayo Owoade
  • 27
  • 5
  • 2
    Use double quotes. https://www.php.net/manual/en/language.types.string.php – Sammitch Oct 15 '21 at 21:08
  • @Sammitch Doubles on the variables didn't work. – Ayo Owoade Oct 15 '21 at 22:04
  • 1
    They should work. Alternative, you need to concatenate the strings and the variables together: `$homepage = file_get_contents('http://www.dataserver.com/getfeed/72062b24e00c4aa4ad7208d98c02bb39/h2h/'.$t1.'/'.$t2);`. If that doesn't work, you're doing something else wrong. – Jacob Mulquin Oct 15 '21 at 23:01
  • @mulquin. Concatenation worked. I added an unnecessary quote at the end of the string before. Thanks. – Ayo Owoade Oct 16 '21 at 05:23

0 Answers0