Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在PHP中读取文件时使用2个定界符_Php_File - Fatal编程技术网

如何在PHP中读取文件时使用2个定界符

如何在PHP中读取文件时使用2个定界符,php,file,Php,File,我正在尝试创建一个在线测验web应用程序,我一直在阅读有问题的文件。请在此处输入代码。这是文件: @$!#include<stdio.h> void main() { printf(); scanf(); } @$!#include<stdio.h> void main() { printf(); scanf(); } @$!#include<stdio.h> void main() { printf(); scanf(); } <?php $fi

我正在尝试创建一个在线测验web应用程序,我一直在阅读有问题的文件。请在此处输入代码。这是文件:

@$!#include<stdio.h>
void main()
{
printf();
scanf();
}
@$!#include<stdio.h>
void main()
{  
printf();
scanf();
}
@$!#include<stdio.h>
void main()
{
printf();
scanf();
}
<?php
$filename = "update.txt";
$contents =  nl2br(file_get_contents($filename));
?>
都在一条直线上。我遗漏了什么?还是有别的办法

<?php
$filename = "update.txt";
$contents =  nl2br(file_get_contents($filename));
?>
您修改的代码:

<?php
$filename = "update.txt";
$contents =  nl2br(file_get_contents($filename));
?>
@$!#include
void main()
{
printf();
scanf();
}
@$!#include
void main()
{
printf();
scanf();
}
@$!#include
void main()
{
printf();
scanf();
} 
<?php
$filename = "newfile.txt";
$contents =  nl2br(file_get_contents($filename));
$delimiter = "\n";
$splits= explode($delimiter, $contents);
foreach ( $splits as $show )
{

$ctr = explode("@$!",$show);
foreach($ctr as $nl)
echo $nl;

} 
?>
#include
void main()
{
printf();
scanf();
}
#include
void main()
{
printf();
scanf();
}
#include
void main()
{
printf();
scanf();
}
为什么OP要“尝试此代码”?一个好的答案总是会有一个解释,说明做了什么以及为什么这样做,不仅是为了OP,而且是为了未来的访客。