Phantomjs-有没有办法将参数传递给 [英] Phantomjs - Is there a way to pass parameters to th

查看:408
本文介绍了Phantomjs-有没有办法将参数传递给的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我在PHP中有这段代码可以调用Phantomjs

Let's say I have this code in PHP to call Phantomjs

shell_exec("phantomjs a-phantomjs-file.js");

是否可以将数据从PHP传递到phantomjs文件?也许有一些命令行参数?

Is there way to pass data from PHP to the phantomjs file? Some sort of commandline arguments perhaps?

推荐答案

此处提供了适用于phantomjs的命令行参数列表:

There is a list of command line arguments for phantomjs here: https://github.com/ariya/phantomjs/wiki/API-Reference

您可以使用字符串连接或内插法从PHP传递它们,只是要注意并小心以防自变量可能来自用户输入而遭受注入攻击.

You can use string concatenation or interpolation to pass them from PHP, just be aware of and careful to protect against injection attacks if the arguments could ever be coming from user input.

这篇关于Phantomjs-有没有办法将参数传递给的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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