duanliang1898 2013-12-18 21:39
浏览 23
已采纳

使用带有GET变量的php filesize函数

I am trying to use the filesize php function to automatically write the filesize in a meta tag I am using.

What I am doing normally is for example

<meta name="DC.format" content="<?= filesize($filename); ?> bytes">

Now, if this is used with the following syntax it returns:

php
<meta name="DC.format" content="<?= filesize("index.php"); ?> bytes">

resulting html
<meta name="DC.format" content="6412 bytes">

But if I use the following syntax I get the following error.

php
<meta name="DC.format" content="<?= filesize("index.php?locale=en_US"); ?> bytes">

resulting html
<meta name="DC.format" content="<br /><b>Warning</b>:  filesize():
stat failed for index.php?es=./&amp;en=./en/&amp;locale=en_US in
<b>D:\xampp\htdocs\casasenmeridabaspul.com-v2\header.php</b>
on line <b>87</b><br /> bytes">

What I suppose is happening is that filesize is getting the filesize of the specific file without doing any php processing or such. How can I calculate the resulting file size after all the server side has processed everything?

With a little more detail:

I have header.php, footer.php and index.php where index.php has the previous 2 included. I was thinking perhaps something like curl but I am not really familiar with it so I would leave it to the experts.

Thanks in advance.

  • 写回答

2条回答 默认 最新

  • doushi9856 2013-12-18 21:43
    关注

    It's not a file. It's text output from the execution of the file. The best you can do is strlen() or mb_strlen() without using HTTP functions / classes I think:

    <?= strlen(file_get_contents("http://www.example.com/index.php?locale=en_US")); ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器