在fopen中使用变量的麻烦 [英] trouble using variable in fopen

查看:103
本文介绍了在fopen中使用变量的麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

供个人使用我正在访问铁路时刻表页面,解析其

内容,然后发送简要相关信息作为主题行

要阅读的电子邮件在手机上。

当我尝试解析第二页时出现问题,其中的网址是我从初始页面派生的。



我不能直接进入第二个(目标)页面但是从初始页面

派生网址并将其放在一个名为$ strTarget的字符串中


在一个特定的实例中,$ strTarget因此读取:
http://www.livedepartureboards.co.uk ...。& J = 1370626& R = 0


如果我像这样硬编码这个字符串

$ fp =

fopen(" http://www.livedepartureboards.co.uk/ldb/train。 aspx?T = FRNCMB ++& J = 1370626& R = 0",

''r'');

然后tar获取页面打开确定并传达时间表信息。

但是,如果我必须这样做,我使用变量$ strTarget来编码它像

这个

$ fp = fopen($ strTarget,''r'');

然后打开的页面总是时间表网站的
$ b $的默认页面b消息,

所请求列车的详细信息不再可用。


我已经检查并仔细检查以确保这确实是什么是
正在发生。

有谁可以解释这里发生了什么?

谢谢

比尔

For my personal use I am accessing a railway timetable page, parsing its
contents and then sending brief relevant information as the subject line of
an email to be read on a mobile phone.
The problem comes when I try to parse a second page, the url of which, I
have derived from an initial page.
I cannot go directly to the second (target) page but from the initial page
derive the url and put it in a string called $strTarget

In one particular instance $strTarget reads thus:
http://www.livedepartureboards.co.uk...&J=1370626&R=0

If I hard code this string like this
$fp =
fopen("http://www.livedepartureboards.co.uk/ldb/train.aspx?T=FRNCMB++&J=1370626&R=0",
''r'');
then the target page opens ok and conveys the timetable information.
However if, as I have to do, I code it using the variable $strTarget like
this
$fp = fopen($strTarget, ''r'');
then the page that opens is always the timetable site''s default page for the
message,
"Details for the requested train are no longer available."

I have checked and double checked to make sure this is indeed what is
happening.
Can anyone explain what is going on here?
Thanks
Bill

推荐答案

strTarget


在一个特定实例中
strTarget

In one particular instance


strTarget因此读取:
http://www.livedepartureboards.co.uk ...。& J = 1370626& R = 0


如果我硬编码这个st这样的戒指
strTarget reads thus:
http://www.livedepartureboards.co.uk...&J=1370626&R=0

If I hard code this string like this


fp =

fopen(" http://www.livedepartureboards.co.uk/ldb/train.aspx? T = FRNCMB ++& J = 1370626& R = 0,

''r'');

然后目标页面打开确定并传达时间表信息。

但是,如果我必须这样做,我使用变量编码
fp =
fopen("http://www.livedepartureboards.co.uk/ldb/train.aspx?T=FRNCMB++&J=1370626&R=0",
''r'');
then the target page opens ok and conveys the timetable information.
However if, as I have to do, I code it using the variable


这篇关于在fopen中使用变量的麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆