need help....combine strings

  • Scott123
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Nov 25, 2008
  • Posts: 10
  • Status: Offline

Post January 6th, 2009, 3:26 pm

Code: [ Select ]
 
$authcode="12345"
$nexturl="\"http://www.mysite.com/up-load.php?confirm=".$authcode."\"";
 
#This works
$get_content = file_get_contents("http://www.mysite.com/up-load.php?confirm=123456")
 
#This does not work
$get_content = file_get_contents($nexturl);
 
  1.  
  2. $authcode="12345"
  3. $nexturl="\"http://www.mysite.com/up-load.php?confirm=".$authcode."\"";
  4.  
  5. #This works
  6. $get_content = file_get_contents("http://www.mysite.com/up-load.php?confirm=123456")
  7.  
  8. #This does not work
  9. $get_content = file_get_contents($nexturl);
  10.  


why????

Help!!

:cry: Thanks.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post January 6th, 2009, 3:26 pm

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post January 6th, 2009, 4:27 pm

Arguments only need quotes around them when they're being passed as string literals. When you pass a variable name instead of a string literal, for example passing $nexturl instead of "http://...", the contents of that variable do not need to include quotes.

So where you're including escaped double quotes like \", the function you're passing the argument to considers that first quote the first character of the argument instead of the "h" from http:// like it wants.
Strong with this one, the sudo is.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 247 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.