草庐IT

put_string

全部标签

php - file_put_contents 无法在包含路径中创建文件

我正在尝试在桌面上创建一个文本文件。我使用set_include_path()创建了一个包含路径,但该文件是在我的xampp/htdocs文件夹中创建的。我如何在我的桌面上创建该文件夹??这可能吗??set_include_path(',;c:/users/shimantta/Desktop');echofile_put_contents("/test.txt","HelloWorld.Testing!",FILE_USE_INCLUDE_PATH); 最佳答案 包含路径是PHP在包含/需要文件时搜索的路径,而不是在写入文件时搜索的

php - file_put_contents(.../bootstrap/cache/services.json) : failed to open stream: No such file or directory

我在运行任何phpartisan命令时一直收到此错误。[ErrorException]file_put_contents(/Applications/MAMP/htdocs/code/bheng/md-bheng/bootstrap/cache/services.json):failedtoopenstream:Nosuchfileordirectory我该如何阻止它? 最佳答案 编辑-如果services.json文件不存在,运行phpartisanserve然后停止强制创建文件。请参阅:laravelservices.jsonn

php - PHP 中的正则表达式 : find the first matching string

我想在非常非常长的文本中找到第一个匹配的字符串。我知道我可以使用preg_grep()并获取返回数组的第一个元素。但是如果我只需要第一场比赛(或者我知道提前只有一场比赛),这样做效率不高。有什么建议吗? 最佳答案 preg_match()?preg_match()returnsthenumberoftimespatternmatches.Thatwillbeeither0times(nomatch)or1timebecausepreg_match()willstopsearchingafterthefirstmatch.preg_m

php - 使用 PHP 和 CURL 发出 PUT 请求

首先,我的工作基于以下假设:根据REST架构,您可以使用PUT创建新资源,在我的例子中是一个包含用户提供的附加信息的文件。如果这个概念不正确,请告诉我,这样我就不会从架构的角度提出错误的问题。我看到有两件事与使用CURL的PUT请求相关。使用以下方法,您可以像普通POST请求一样发送值数组。curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"PUT");并使用这个:curl_setopt($ch,CURLOPT_PUT,1);可以上传文件。这两个选项是否相关?它们是在同一个PUT请求中发送文件和一些元信息的互补方式吗?上传文件并为其发送附加信息(如类别和描述)

php - 更改错误日志输出格式 : ini_set ('error_append_string' , 'string' ) 和 ini_set ('error_prepend_string' , 'string' ) 什么都不做

这是我告诉php要做的:希望我能在一个文件中报告所有错误,在消息前加上“PRE”,在消息后加上“APP”。(我的目标是把PRE和APP做成/n/r什么的。。。)但是我的报错日志是这样的:[14-May-201300:16:26]PHPNotice:Undefinedvariable:nonexistentvariablein/home/www/dir/index.phponline14[14-May-201300:16:28]PHPNotice:Undefinedvariable:nonexistentvariablein/home/www/dir/index.phponline14没

PHP PDO : Charset=UTF8 : An invalid keyword charset was specified in the dsn string

我正在使用sqlsrv驱动程序连接到带有PDO的MSSQL服务器。PHP版本为5.3.24。工作连接如下所示:$dsny="sqlsrv:Server=xx1;Database=xx2";$usery='xx3';$passwordy='xx4';$dbhy=newPDO($dsny,$usery,$passwordy);**但是我需要设置字符,然后我试试这个:$dsny="sqlsrv:Server=xx1;Database=xx2;charset=utf8";$usery='xx3';$passwordy='xx4';$dbhy=newPDO($dsny,$usery,$passw

php - 可捕获的 fatal error : Object of class PDOStatement could not be converted to string in line 114

这个问题在这里已经有了答案:returnonevaluefromdatabasewithmysqlphppdo(3个答案)关闭23天前。我正在尝试向我的数据库中添加一些数据,但我在第114行的/var/www/mandje.php中收到错误Catchablefatalerror:ObjectofclassPDOStatementcouldnotbeconvertedtostringin/var/www/mandje.php。这是我正在使用的代码:foreach($_SESSION["cart"]as$id=>$value){$query=$db->query('SELECT*FROMP

php - 使用 put 对象和 s3 捕获错误

我正在使用S3phpsdk及其幼虫实现将对象放到S3上。try{$s3->putObject(array('Bucket'=>'mybucket','Key'=>'abc','Body'=>$img->encode(null,90),'ACL'=>'public-read','ContentType'=>$img->mime()));}catch(S3Exception$e){var_dump('error');die();}但是上面的代码好像并没有捕捉到错误。我设置了不正确的存储桶,但仍然出现错误:type:Aws\S3\Exception\NoSuchBucketException

php - 通知消息 : Array to string conversion

我是codeigniter和php的初学者,我正面临这个问题APHPErrorwasencounteredSeverity:NoticeMessage:Undefinedvariable:queryFilename:inc/header_main_view.phpLineNumber:175APHPErrorwasencounteredView:id_task;?>name;?>20%20%Completeindex.php/dashboard/g_tasks_menu">ViewalltasksControllerpublicfunctionget_todo($id=null){$t

php - 是否有匹配 "string"和 "Object that implements __toString()"的 native 接口(interface)?

我们有实现__toString()的对象:classFoo{publicfunction__toString(){return'bar';}}然后我们有返回string或实现__toString()的对象的函数,如上面的示例。当对字符串使用返回类型string时当然有效:functiongetString():string{return'Works!';}Foo类型的返回对象不起作用,因为它不是字符串:functiongetString(Foo$foo):string{return$foo;//FatalTypeError!}是否有任何PHP接口(interface)可用于类型提示st