草庐IT

php - 如何在 bash 中执行 php 脚本?

我需要在shell脚本中解析uri。所以,我尝试在bash中使用php,如下所示。#!/bin/shuri="http://www.google.com?key=valuekey="host"value=$(php-r"$parse=parse_url('$uri');echo$parse['$key']")它显示了以下错误。PHPParseerror:syntaxerror,unexpected'='inCommandlinecodeonline1有人可以帮助如何在bash中使用嵌入式php? 最佳答案 一种廉价的调试方法是使用e

php - 火力基地: "Could not parse auth token."

你好,我正在使用带有php的firebase并使用这个library.我收到此错误“无法解析身份验证token。”我的授权token是正确的,因为我也使用了与node.js相同的token。我的代码是这样的require"vendor/autoload.php";constDEFAULT_URL='https://xxxxxxxxx.firebaseio.com';constDEFAULT_TOKEN='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';$firebase=new\Firebase\FirebaseLib(DEFAULT_URL,DEFAULT_TOK

PHP parse_ini_file() - 它看起来在哪里?

如果我调用php的parse_ini_file("foo.ini"),它会在什么路径中查找foo.ini?包含路径?该函数的文档没有提及它。 最佳答案 parse_ini_file的文件名参数是一个标准的php文件名,因此与使用fopen打开文件的规则相同。.您必须指定绝对文件路径(“/path/to/my.ini”)或相对于当前工作目录的路径(“my.ini”)。参见getcwd对于您当前的工作目录。与默认的fopen命令不同,如果指定了相对路径(“my.ini”),parse_ini_file将在搜索当前工作目录后搜索包含路径。

php - 是否有可靠且不易出错的 parse_str() 替代方案?

有没有可靠的替代parse_str()解析查询字符串的函数?我发现它非常困惑且容易出错,特别是当查询字符串来自外部服务(并且您无法完全控制它)时:$error="Errormessage";parse_str("param1=hello&error=false");//Overrides$errorparse_str($externalQuery);//Whichvariablesaresettedandwhichnot? 最佳答案 将可选的第二个参数传递给parse_str()它将把值放在关联数组中,而不是创建/覆盖变量。来自ph

php - fatal error : Uncaught exception 'Parse\ParseException' with message in parse sdk

我使用以下代码获取数据库数据:require'autoload.php';$app_id='AAAAA';$rest_key='XXXXX';$master_key='RRRRR';useParse\ParseObject;useParse\ParseQuery;useParse\ParseACL;useParse\ParsePush;useParse\ParseUser;useParse\ParseInstallation;useParse\ParseException;useParse\ParseClient;useParse\ParseAnalytics;useParse\Par

php - date_parse_from_format 到 unix 时间戳

我对date_parse_from_format()方法有疑问:$parsed=date_parse_from_format("YdMH:iT",'201228Nov21:00CET');Returnsassociativearraywithdetailedinfoaboutgivendate.这将返回一个包含一些日期信息的数组。但是有什么方法可以将它转换为unix时间戳吗? 最佳答案 约翰,下面是如何在您的场景中实现mktime的具体示例:$parsed=date_parse_from_format("YdMH:iT",'2012

php - parse_url() 在传递 example.com 时返回错误

根据以下代码,如果$host_name类似于example.comPHP返回通知:Message:Undefinedindex:host但在完整的URL,如http://example.comPHP返回example.com。我尝试了带有FALSE和NULL的if语句,但没有成功。$host_name=$this->input->post('host_name');$parse=parse_url($host_name);$parse_url=$parse['host'];如何修改脚本以接受example.com并返回它? 最佳答案

PHP "parse error, expecting ` T_STRING' "- 请帮忙提供代码

我正在尝试使用MVC原则构建动态php站点。我在WinXP上使用WAMP。代码如下:索引.php:标题.php:'?>页脚.php:用户.php:userName;}}?>此代码在User.php的第9行(即get函数声明处)导致php错误。错误信息是:Parseerror:parseerror,expecting`T_STRING'inC:\wamp\www\Projet\User.phponline9非常感谢您的帮助....谢谢,JDelage 最佳答案 function$getUserName()应该是functiongetU

php - 在我的 MVC 框架中解析错误 : parse error, 期望 `T_FUNCTION'

这个问题不太可能帮助任何future的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visitthehelpcenter.关闭9年前。我正在关注CreateyourFirstTinyMVCBoilerplatewithPHP教程,据我所知——我的代码与Jeff的代码相同……但我收到此错误:Parseerror:parseerror,expecting`T_FUNCTION'inD:\wamp\www\MVC_test\application\load.phponline8load.php

PHP:使用 preg_match 获取 url 变量?

http://www.example.com?id=05或http://www.example.com?id=05&name=johnny这是一个字符串。我想从中获取$id的值。它的正确模式是什么? 最佳答案 您不需要正则表达式(除非您有充分的理由,否则您以后不应该直接跳到正则表达式)。使用parse_url()使用PHP_URL_QUERY检索查询字符串。然后将其与parse_str()配对.$querystring=parse_url('http://www.mysite.com?id=05&name=johnny',PHP_U