草庐IT

cookie_file

全部标签

php - php中setcookie和$_COOKIE的区别

通过setcookie()和$_COOKIE设置cookie有什么区别吗?有时,当通过setcookie设置cookie时,我无法通过$_COOKIE['cookie_name']获取该cookie的值。但是jsconsole.log紧跟在setcookie,显示cookie已设置,但如果我尝试通过$_COOKIE获取cookie的值,我得不到更新后的值。我很困惑..!! 最佳答案 你不能用像这样的一些代码实际上“设置”一个cookie:$_COOKIE['cookie']=$my_var;所有这一切都是向$_COOKIE数组添加一

php - Form::file:如何在验证错误后和/或更新时使用 Input::old 重新填充?

在我的PhotosController中,我试图修改编辑操作,以便它在Form::file()输入字段中显示现有值(并且,如果验证失败,它会重新填充该字段)。if($validation->passes()){//savestheimageontheFSandupdatesthedbentry}returnRedirect::route('photos.edit')->withInput(Input::all())->withErrors($validation)->with('message','Therewerevalidationerrors.');上传过程正常,但当我查看现有记

php - Windows 更新警告 : Unknown: failed to open stream: No such file or directory in Unknown on line 0

Warning:Unknown:failedtoopenstream:NosuchfileordirectoryinUnknownonline0Fatalerror:Unknown:Failedopeningrequired'C:/School/OneDrive-Noorderpoort/PHP/htdocs/Jaar1/Blok1/Les7/oefening16.php'(include_path='C:\xampp\php\PEAR')inUnknownonline0经过长时间的Windows更新后,当我尝试通过本地主机打开php文件时突然出现此错误。我该如何解决这个问题?

带有密码保护 url 的 php simplexml_load_file()

知道答案的人的简单问题...$xml=simplexml_load_file("http://url/path/file.xml");此url受.htaccess保护,如何将登录名/密码作为参数传递给函数? 最佳答案 $xml=simplexml_load_file("http://username:password@url/path/file.xml");试试看:) 关于带有密码保护url的phpsimplexml_load_file(),我们在StackOverflow上找到一个类似

PHP 评估后的 PHP file_get_contents

我知道如何使用file_get_contents和fopen等,但是当我对自己的文件之一执行此操作时,我得到的是文字字符串,也就是说,代码没有经过预处理!我如何在不使用require等的情况下从文件中导入文本,因为我想将值存储到字符串中 最佳答案 参见themanual上的示例#5和#6.直接从那里获取:$string=get_include_contents('somefile.php');functionget_include_contents($filename){if(is_file($filename)){ob_start

php - 将 session ID 存储在 cookie 中是否比 get var 更好?

标题几乎说明了一切。cookies对我来说似乎有一些好处;不过,我会等着看别人怎么说。此外-假设cookie更好,可以做些什么来更好地通过GET变量传递session?具体来说,我正在考虑PHP;但是,这应该普遍适用。 最佳答案 与GETvar相比,将其存储在cookie中至少有一个优势,即sessionID的URL永远不会被任何用户添加为书签。 关于php-将sessionID存储在cookie中是否比getvar更好?,我们在StackOverflow上找到一个类似的问题:

php - 具有多个字段时 $_FILES 数组的奇怪格式

我有一个表单,其中包含一些这样的字段:我希望我会做这样的事情:Array([images]=>Array([0]=>Array([name]=>test.jpg[type]=>image/jpeg[tmp_name]=>/tmp/nsl54Gs[error]=>0[size]=>1715)[1]=>Array([name]=>test.jpg[type]=>image/jpeg[tmp_name]=>/tmp/nsl54Gs[error]=>0[size]=>1715)[2]=>Array([name]=>test.jpg[type]=>image/jpeg[tmp_name]=>/t

php - file_get_contents 对 'https://en.wikipedia.org/wiki/Category:Upcoming_singles' 的变量响应

file_get_contents('https://en.wikipedia.org/wiki/Category:Upcoming_singles');使用Chrome网络浏览器访问同一地址(显示4种产品)返回不同的响应(2种产品)。经检查,我怀疑这可能与有关Savedinparsercachekeywith...timestamp...在返回的html中。当我使用file_get_contents()时,时间戳较旧关于如何使用file_get_contents()获取最新信息有什么想法吗?谢谢! 最佳答案 假设file_get_

php,realpath 与 realpath + file_exists 用法

出于性能原因,我们应该只使用realpath()而不是realpath()+file_exists()在检查文件或目录是否存在时??案例A::if(realpath(__DIR__."/../file.php")===false)案例B::if(file_exists(realpath(__DIR__."/../file.php"))===false)我认为CASEA完成了工作,而CASEB完成了两次工作。 最佳答案 不仅情况B是多余的(因为根据docs,如果路径无法解析或文件不存在,则realpath返回false),如果文件不存

php - 性能 : file_get_contents(), 相对和绝对 URL

如果我在file_get_contents()中使用相对路径作为参数,是否有任何性能优势?file_get_contents("../../mypage.php");v/sfile_get_contents("http://.../mypage.php");内部如何处理file_get_contents()? 最佳答案 使用本地文件与使用远程文件肯定会有明显的性能差异-即使“远程”文件位于您的本地服务器上。当您使用本地/相关文件时,例如file_get_contents("../../mypage.php");,它会直接在服务器上加