开发者

cURL doesn't work from command line?

I wrote a script to parse some data from a website using cURL and it works fine when I run it in my browser, however when I want to run it in the command line I get the error "call to un开发者_开发知识库defined function curl_init()". Do php scripts run under different settings from the command line?


This is happening because you are simply trying to call a PHP function from bash. If you have curl installed in your linux environment then the command should simply be curl [-options] [url]. The simplest of them being something like:

$ curl http://someurl.com/path/to/xmlfile.xml

You can test for this from the command line by tying "$ which curl" (without the quotes of course). That will give you the path to where it is stored in case you have to use the full path. (e.g. /usr/bin/curl [-options] [url]).

EDIT: after having re-read your question I realized that I dumbly missed the fact that you said you were trying to run the PHP script from the command line and not curl itself. And now I, too, am stumped by your problem. Sorry!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜