SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast synth's Avatar
    Join Date
    Nov 2002
    Location
    1, The Way
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    String question (single quotes, double quotes mystery)

    Hi all

    Is there any way to disable variable parsing within a string, at runtime?

    I'm afraid I can't explain it very well, but I am having a weird problem, which involves strings with currency sums like '$900' gets the first three chars in front chopped off ('$90'), leaving the 0 behind.

    What triggers this is a string concatenation operation - if I echo the string to output, everything is fine... if I tie the string to the end of another one, and I echo the new string, I get the chopped off version!

    What is worse is I can't seem to replicate this behaviour with any test code that I write.

    I'm tearing my hair off!

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,449
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Why not post the code that is the problem so we can look at it?

  3. #3
    Grumpy Minimalist
    Join Date
    Jul 2006
    Location
    Ontario, Canada
    Posts
    424
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I understand you correctly, the problem is somewhere else in your code; could you please post it so that we can figure out what you're doing wrong?

    This seems to describe your problem, but works fine here:
    Code PHP:
    <?php	
    	$str1 = '$900';
    	var_dump($str1);      //Prints string(4) "$900"
     
    	$str2 = '' . $str1;
    	var_dump($str2);      //Prints string(4) "$900", not string(1) "0"
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •