GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PhP Question (https://gfy.com/showthread.php?t=808225)

ChargebackJoe 02-17-2008 04:24 AM

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' .

rowan 02-17-2008 04:29 AM

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");

ChargebackJoe 02-17-2008 04:36 AM

just tried it, still overwrites, thanks though

Quote:

Originally Posted by rowan (Post 13793950)
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");


Swish 02-17-2008 06:03 AM

You can just say:
Code:

$htmlfile = "./html/{$name}{$num}.html";
Easier :thumbsup

maggie2007 02-17-2008 09:28 AM

Swish, I think that { and } can be removed, right? :)

testpie 02-17-2008 10:23 AM

Quote:

Originally Posted by Swish (Post 13794090)
You can just say:
Code:

$htmlfile = "./html/{$name}{$num}.html";
Easier :thumbsup

Isn't that the same as:
PHP Code:

$htmlfile "./html/".$name.$num.".html"


Swish 02-18-2008 03:11 PM

Quote:

Originally Posted by maggie2007 (Post 13794467)
Swish, I think that { and } can be removed, right? :)

In this instance, yes.

Quote:

Originally Posted by testpie (Post 13794636)
Isn't that the same as:
PHP Code:

$htmlfile "./html/".$name.$num.".html"


Yes.


All times are GMT -7. The time now is 09:28 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123