用php创建和写入文件 [英] Creating and writing files with 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屋!