草庐IT

boolean-operations

全部标签

php - 尝试连接到 Microsoft Graph 时出现 "Insufficient privileges to complete the operation"

我想配置我的Symfony4应用程序以使用msgraph-sdk-php阅读和发送电子邮件图书馆。我的应用程序将从单个帐户读取和发送电子邮件,我不想将其密码暴露给应用程序的用户。因此,我不会使用OAuth进行登录。我的第一个体验是这段代码(检索邮箱用户资料):post($url,['form_params'=>['client_id'=>$clientId,'client_secret'=>$clientSecret,'resource'=>'https://graph.microsoft.com/','grant_type'=>'client_credentials',],])->g

php - 如何显示那些被@-operator - Error Control Operators 禁用的错误?

我正在使用一些使用@错误沉默运算符的外部库。库正在生成一些错误,并且由于@运算符隐藏了它,因此很难指出错误发生的确切位置。有什么方法可以在不对代码进行任何实际更改的情况下轻松禁用代码中的@-operator?我试过ScreamPecl扩展,但它似乎不起作用。当我使用PHP7时,它适用于PHP5.6版本。Scream扩展已安装并通过使用scream.enabled=1在php.ini中启用(根据他们的文档),但错误仍未显示或记录。 最佳答案 您无法禁用@符号的行为,但您仍然可以使用自己的错误处理程序记录/处理这些错误。来自docs:I

php - 正则表达式帮助 : how to match only either pattern in a regex that contains "or" operator?

我正在使用php的preg_replace().基本上我有2种可能的字符串匹配:你好现实世界问候这是我希望完成的:HelloRealWorldGreetings规则解释:如果字符串包含空格,插入在第一个空格字符之后。如果字符串不包含空格(一个单词),则插入就在字符串的中间(+/-如果奇数字符计数)。到目前为止,我已经想出了一个长期有效的解决方案:",$str,1):preg_replace("/.{".round(strlen($str)/2)."}/","$0",$str,1);?>但是,我相信它可以通过一个更短、更优雅的正则表达式来完成,只有一个preg_replace()。打电话

php - curl 错误 28 : Operation timed out after 2000 milliseconds with 7276200 out of 23000995 bytes received

描述我在Laravel项目中使用Guzzle。当我向返回大量有效负载的API发出请求时,我遇到了内存崩溃。我在CURL.php类的顶部有这个。我有使用Guzzle的get()。useGuzzleHttp\Exception\GuzzleException;useGuzzleHttp\Client;useGuzzleHttp\FORCE_IP_RESOLVE;useGuzzleHttp\DECODE_CONTENT;useGuzzleHttp\CONNECT_TIMEOUT;useGuzzleHttp\READ_TIMEOUT;useGuzzleHttp\TIMEOUT;classCUR

php - 在 PHP 中检查来自 JQuery POST 的 boolean 变量

我是PHP新手。我在jquery中有一个名为editMode的变量设置为false。我在jquery中使用$.post()在php函数中传递变量。但是当我检查它的值时,值是好的,但是if语句没有按预期的方式运行。这是我的代码:jQuery(只是一个片段):vareditMode=false;$(document).ready(function(){//somefunctionthathandlesUIinputthattriggerseditMode=true$("#form").submit(function(event){event.preventDefault();varfNam

php - If 条件 : Why turning a boolean into an integer?

我看到了这样的情况:if((int)method_exists($this,$this->endpoint)>0)这背后是什么?与明显相比有什么优势if(method_exists($this,$this->endpoint))?(来源:http://coreymaynard.com/blog/creating-a-restful-api-with-php/) 最佳答案 我看不出将它变成整数有什么好处。因为method_exists已经返回一个bool值。这是一种冗长且无用的编码方式。如果语句需要一个bool值,并且method_e

php - 验证码 file_get_contents() : SSL operation failed

我正在为我的网页使用GooglereCaptcha。在测试模式下一切正常。无SSL。当我在生产环境中测试我的网页时,出现以下错误:Warning:file_get_contents():SSLoperationfailedwithcode1.OpenSSLErrormessages:error:14090086:SSLroutines:SSL3_GET_SERVER_CERTIFICATE:certificateverifyfailedin/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Post.phponline68Warni

php - Boolean和Integer是序列化后的字符串

我正在使用WordPressupdate_post_meta像这样保存一个数组$obj=array('array'=>array(1,'zwei',!!3),'string'=>'abc','bool'=>true,'bool2'=>false,'integer'=>1,'integer2'=>17);update_post_meta($post_ID,'my-key',$obj);但是如果我检查我得到的原始字段a:6:{s:5:"array";a:3:{i:0;i:1;i:1;s:4:"zwei";i:2;s:1:"1";}s:6:"string";s:3:"abc";s:4:"bo

PHP:strtotime 返回类型为 "nothing"的 "boolean"

我有变量$EDate,我使用strtotime函数和这个具有不同值的变量,结果如下:$EDate=10-21-2013;echo"strtotime($EDate)";theresult=nothingandthetypeisboolean$EDate=09-02-2013;echo"strtotime($EDate)";theresult=1360386000andthetypeisinteger$EDate=09-30-2013;echo"strtotime($EDate)";theresult=nothingandthetypeisboolean$EDate=09-30-2013

php - boolean 针可以传递给 in_array 吗?

我可以将false作为针传递给in_array()吗?if(in_array(false,$haystack_array)){return'!';}else{return'C';}$haystack_array将只包含boolean值。干草堆表示多个写入查询的结果。我试图找出其中是否有任何返回错误,因此未完成。 最佳答案 PHP不会关心您作为“针”传入的内容,但您可能还应该为in_array使用第三个(可选)参数以使其成为“严格”比较。PHP中的“false”将测试为等于0、''、""、null等。..