如何在PHP中读取文件时使用2个定界符
我正在尝试创建一个在线测验web应用程序,我一直在阅读有问题的文件。请在此处输入代码。这是文件:如何在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
@$!#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,而且是为了未来的访客。