用php创建和写入文件 [英] Creating and writing files with php

查看:109
本文介绍了用php创建和写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在PHP中将变量传递给file_get_contents?我得到的错误,并想知道如果这是我的语法。

$ p $ $ page = file_get_contents('http://localhost/home/form.php?id = {$数据[ 'form_id']}');
$ fp = fopen('form.html','w +');
fputs($ fp,$ page);
fclose($ fp);


解决方案使用这个语法,使用 quotes而不是' ones。

$ page = file_get_contents(http://localhost/home/form.php?id= {$ data ['form_id']});





$ page = file_get_contents('http://localhost/home/form.php?id ='。$ data [ 'form_id']);


Is it possible to pass a variable to 'file_get_contents' in php? Am getting errors and wondered if it was my syntax. Am using the code below.

$page=file_get_contents('http://localhost/home/form.php?id={$data['form_id']}');
$fp=fopen('form.html','w+');
fputs($fp,$page);
fclose($fp);

解决方案

To use this syntax, use " quotes instead of ' ones.

$page=file_get_contents("http://localhost/home/form.php?id={$data['form_id']}");

or

$page=file_get_contents('http://localhost/home/form.php?id='.$data['form_id']);

这篇关于用php创建和写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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