开发者

sort of Include in an include - php

Here is what we have :-

We currently have a file system like this

$price = '3.00'; - this in turn is then included into a different file for use within the template system.

what we want to do may seem a bit long winded but it seems the easiest to us to get around.

what we are going to have is one file which will static price and will be updated via a .net application so all the .php contains is 3.00

then... we come back to the main file and this is where we are getting stuck

we have tried methods like this

<? 
$file = file_get_contents('/home/habbo/www/order/pricex2.php');
echo $file;
$price = '$file';
?&开发者_C百科gt;

we have tried to put an include within the = ' '; bit and that doesnt seem to work and im not too sure how we are meant to add it , i thought the $file might of worked but it just simple outputs the $file

is there much i am doing wrong


Erm, I think you need:

$price = $file;

or (slower):

$price = "$file";

Since PHP variables are not interpolated within single-quoted strings.

You can convert it into a floating point number like this:

$price = floatVal($file);

// or
$price = (float)$file;

// or (icky, but..)
$price = $file + 0.0;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜