-2

I would like change the 1 in the URL below and pass PHP variable pulled from the website URL. I have everything else working except I'm having trouble getting a variable working in the middle of the URL file_get_contents below.

$listingstring = file_get_contents('http://example.com/1/lsitngs/');

$listingstring = file_get_contents('http://example.com/?variable/lsitngs/');
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
bradpotts
  • 329
  • 1
  • 14

1 Answers1

8

Use double quotes for your string so you can place a variable inside of it and have it interpolated:

$listingstring = file_get_contents("http://example.com/$variable/lsitngs/");

You can also use concatenation:

$listingstring = file_get_contents('http://example.com/'.$variable.'/lsitngs/');
John Conde
  • 217,595
  • 99
  • 455
  • 496