我正在整理一个搜索引擎在php中循环一些目录和回声过滤结果.
我的问题是,在所有搜索完成之前不会执行回显,导致页面保持空白,直到脚本完成.
这是正常的吗?如果是这样,我怎样才能在调用回声时显示搜索结果?
我也将最终将结果中的图像写入屏幕.可以通过同时利用客户端和服务器端来调用JS document.write函数来代替回应所有内容吗?
编辑:这是迭代的代码.我有一个标记系统,但此部分已被注释掉了...
function checkTags($dir, $search){
global $tag;
$filesInDir = array_map('strtolower', scandir($dir)); // lower case the files
$filterOut = array('.','..');
$filesInDir = array_diff($filesInDir, $filterOut); // get rid of the current '.' and parent '..' values
// print_r($filesInDir);
foreach($filesInDir as $file) {
if($file == $tag) { // found a tag
echo 'found tag: '.$file.'<br>';
/* $tagDir = dirname($tag);
$tagContents = strtolower(file_get_contents($file).'<br>'.$tagDir); // adding full path to include parent dirs in tag searching
foreach($search as $s){
if(strpos($tagContents, $s) …Run Code Online (Sandbox Code Playgroud) 我通过在线教程学习n00b.我在名为"response.php"的"服务器端"测试文件中有以下代码:
<?php
if (isset($_POST))
{
$answer = $_POST;
echo json_encode($answer);
} else {
echo json_encode(array('status' => false, 'msg' => 'no good'));
}
?>
Run Code Online (Sandbox Code Playgroud)
echo将数据返回到.ajaxjquery回调时,我是否总是必须使用?是否有其他方法将数据发送回客户端?
好吧,我有一个网站签名.但是因为一些头问题我不得不把它放在另一个文件中并使用echo.这是代码:
<h1>Create your European Trucking signatures</h1>
<?php
echo '<img src="SigGen.php?player=$Playername&score=$Score&money=$Money" />';
?>
</div>
Run Code Online (Sandbox Code Playgroud)
但它显示了一个破碎的图像.但是当我去SigGen.php本身时,它确实显示在这里:
http
://european-trucking.com/SigGen.php?player_name = Thimo这是SigGen的代码:
<?
/*
***Made by: Nodroz***
*** Enjoy your signatures! ***
*/
$username="10528_Thimo"; //Your MySQL Username.
$password="*********"; // Your MySQL Pass.
$database="10528_Thimo"; // Your MySQL database.
$host="95.211.***.***"; // Your MySQL host. This is "localhost" or the IP specified by your hosting company.
$player_name=$_GET['player_name']; // This gets the player his name from the previous page.
/* Next, we will make a connection to the …Run Code Online (Sandbox Code Playgroud) 我在 PHP Echo 函数中有一个名为“Delete”的链接。当用户单击它时,将调用 delete.php 页面,并从数据库中删除所选书籍。因此,我想插入一个确认框,询问用户是否确定删除该书,但我不知道该怎么做。
这是代码:
echo "<td><a class = 'echo_link' href='delete-book.php?ID={$Book->ID}'> Delete </a></td> \n";
Run Code Online (Sandbox Code Playgroud) 我有一个日志文件和简单的bash脚本:
echo -e "$date $totalsize $dupsize $per" > log.txt
Run Code Online (Sandbox Code Playgroud)
但是当我执行这个脚本时,它会写第一行log.txt并向我显示最后一个数据.
我试过了\n但是没有用.
执行此脚本时,如何写入新行?
我有一个 Wordpress 网站,想向具有指定用户代理的用户显示指定的内容。这是我所做的:
<?php
$user_agent = $_SERVER['HTTP_USER_AGENT'];
if (strpos( $user_agent, 'CostumizedAgent') !== false)
{
echo "<html><body>Show Only this codes</body></html>
}
else
{
// Show normal website
}
?>
Run Code Online (Sandbox Code Playgroud)
在用户代理不包含CostumizedAgent单词的情况下,将向用户显示普通网站(普通的 wordpress 网站),但如果包含单词,CostumizedAgent它只会向用户回显指定的 HTML 代码。我用这个来创建一个简单的秘密内容!(我知道这不是应该做的:D)
所以我该怎么做?我必须放置哪些代码else?我应该把所有代码放在哪里?(在网站的所有页面上)
我写了一个简单的perl脚本
#!/usr/bin/perl
my $str = "hello\nworld";
my $cmd = "echo -e $str";
system($cmd);
Run Code Online (Sandbox Code Playgroud)
输出是:
-e hello
sh: 2: world: not found
Run Code Online (Sandbox Code Playgroud)
这不是预期的.我想要的是这个:
hello
world
Run Code Online (Sandbox Code Playgroud)
注意"echo -e"可以正常工作,因为当我运行以下命令时,
echo -e "hello\nworld"
Run Code Online (Sandbox Code Playgroud)
输出是正确的.
任何解决方案
例如,我有一个数据库和 1 个表,表里面是 id、user、votes,
id = primary and auto increment
users = varchar
votes = int
Run Code Online (Sandbox Code Playgroud)
我如何总计投票字段内的值并回显它?
我在centos上,我做到sudo echo 'testline'>>/etc/test/test了说-bash: /etc/test/test: Permission denied
但是,当我执行sudo vi /etc/test/test并插入testline并执行时:wq它写得很好,为什么会发生这种情况?
我想在图片文件夹中找到一些文件类型,我在文件夹中创建了以下 bash 脚本/home/user/pictures:
for i in *.pdf *.sh *.txt;
do
echo 'all file types with extension' $i;
find /home/user/pictures -type f -iname $i;
done
Run Code Online (Sandbox Code Playgroud)
但是当我执行 bash-script 时,对于位于基本目录 /home/user/pictures. 而不是 echo 'All File types with Extension *.sh' 该命令解释基目录的变量:
all file types with extension file1.sh
/home/user/pictures/file1.sh
all file types with extension file2.sh
/home/user/pictures/file2.sh
all file types with extension file3.sh
/home/user/pictures/file3.sh
Run Code Online (Sandbox Code Playgroud)
我想知道为什么 echo - 命令不打印“所有带有扩展名 *.sh 的文件类型”。