PhP Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ChargebackJoe
    Confirmed User
    • May 2006
    • 356

    #1

    PhP Question

    How come when I try
    $htmlfile=sprintf("./html/%s%d.html",$name,$num);

    it works fine but when I try to write $num as a string like so

    $htmlfile=sprintf("./html/%s%s.html",$name,$num);

    the resulting string gets partially overwritten. Is there a better way to do that? By the way I obtain $name and $num from 'list' of the out of 'explode' .
    Buy PPC Traffic
  • rowan
    Too lazy to set a custom title
    • Mar 2002
    • 17393

    #2
    If you want to make sure it's passed to sprintf as a string I think this should work:

    $htmlfile=sprintf("./html/%s%s.html","$name","$num");

    Comment

    • ChargebackJoe
      Confirmed User
      • May 2006
      • 356

      #3
      just tried it, still overwrites, thanks though

      Originally posted by rowan
      If you want to make sure it's passed to sprintf as a string I think this should work:

      $htmlfile=sprintf("./html/%s%s.html","$name","$num");
      Buy PPC Traffic

      Comment

      • Swish
        Confirmed User
        • Mar 2006
        • 1421

        #4
        You can just say:
        Code:
        $htmlfile = "./html/{$name}{$num}.html";
        Easier


        Naughty America - Director of Technology
        It's a CELEBRATION bitches!! For the hottest content promote Naughty America!
        swish at naughtyamerica dot com | ICQ: 226 737 620 | See Who I Am At AdultWhosWho.com!

        Comment

        • maggie2007
          Confirmed User
          • Jan 2007
          • 247

          #5
          Swish, I think that { and } can be removed, right?
          MAGGIE AND HER CRAZY DOLLS'S RATIO KICKS ASS!!!

          Comment

          • testpie
            Mostly retired
            • Apr 2006
            • 3231

            #6
            Originally posted by Swish
            You can just say:
            Code:
            $htmlfile = "./html/{$name}{$num}.html";
            Easier
            Isn't that the same as:
            PHP Code:
            $htmlfile = "./html/".$name.$num.".html"; 
            

            Affiliates: DogFart ~ Domain parking: NameDrive ~ Traffic broker: Traffic Holder

            Comment

            • Swish
              Confirmed User
              • Mar 2006
              • 1421

              #7
              Originally posted by maggie2007
              Swish, I think that { and } can be removed, right?
              In this instance, yes.

              Originally posted by testpie
              Isn't that the same as:
              PHP Code:
              $htmlfile = "./html/".$name.$num.".html"; 
              
              Yes.


              Naughty America - Director of Technology
              It's a CELEBRATION bitches!! For the hottest content promote Naughty America!
              swish at naughtyamerica dot com | ICQ: 226 737 620 | See Who I Am At AdultWhosWho.com!

              Comment

              Working...