有没有人知道在特定页面上禁用插件(即活动)的真正有效方法?有一些插件在网站的某些页面中并不真正需要,并且它们有很多CSS和JavaScript文件,这些文件会降低网站的加载速度,有时可能会与其他文件冲突.
我知道我可以搞乱插件的代码等,但它并没有真正有效.
有任何想法吗?
提前致谢!
我有以下代码:
<?php
class MyTest extends PHPUnit_Framework_TestCase
{
public function testCalculate()
{
$this->assertEquals(2, 1 + 1);
}
}
?>
Run Code Online (Sandbox Code Playgroud)
当我在浏览器中打开PHP文件时,出现以下错误:
致命错误:找不到类'PHPUnit_Framework_TestCase'
但是,如果我使用命令行它可以正常工作:phpunit [local_path_here] /testcase.php
结果:
.
Time: 0 seconds, Memory: 5.00Mb
OK (1 test, 1 assertion)
Run Code Online (Sandbox Code Playgroud)
这是为什么?如何让它在浏览器中运行呢?
我有以下代码:
function playSound(source) {
document.getElementById("sound_span").innerHTML =
"<embed src='" + source + "' hidden=true autostart=true loop=false>";
}
Run Code Online (Sandbox Code Playgroud)
<span id="sound_span"></span>
<button onclick="playSound('file.mp3');"></button>
Run Code Online (Sandbox Code Playgroud)
单击播放后,MP3将被下载,而不是开始播放.但是,它可能需要一段时间,如果它有1 MB.我需要的是预加载(就像你可以用图像做的那样).因此,当页面加载时,mp3将被流式传输,例如,如果10秒后,用户按下"播放"按钮,他将不必等到mp3首先被下载,因为它已经被流式传输.
有任何想法吗?提前感谢任何提示!
我有以下PHP摘录代码:
foreach($afb_replacements as $afb_to_replace => $afb_replacement) {
$sender_subject = str_replace($afb_to_replace, $afb_replacement, $sender_subject);
$ar_subject = str_replace($afb_to_replace, $afb_replacement, $ar_subject);
$final_message = str_replace($afb_to_replace, $afb_replacement, $final_message);
$final_message_text = str_replace($afb_to_replace, $afb_replacement, $final_message_text);
$ar_message = str_replace($afb_to_replace, $afb_replacement, $ar_message);
$ar_message_text = str_replace($afb_to_replace, $afb_replacement, $ar_message_text);
}
Run Code Online (Sandbox Code Playgroud)
所有6个变量都以相同的方式替换(相同的文本用$ afb_to_replace和$ afb_replacement替换所有变量中的相同替换).
我想知道的是:
怎样才能更有效地写出来?也许在一行代码中.我确信有更好的方法,因为这是多余的代码,但目前还没有其他解决方案进入我的脑海.有任何想法吗?
我很好奇你的方法!
我有以下代码:
$('#form_field, #button').bind('change click', function() {
// take action
});
Run Code Online (Sandbox Code Playgroud)
它工作正常.但是,我想在'#form_field'使用'change'时触发相同的操作,'#button'使用'click'(而不是'click_field'使用'click').
我知道可以使用以下代码完成:
$('#form_field').bind('change', function() {
// take action
});
$('#button').bind('click', function() {
// take action
});
Run Code Online (Sandbox Code Playgroud)
但是,我不想重复函数内部的所有代码(//采取行动).它看起来效果不佳,每次我对它进行更改时我都需要编辑两次.
有任何想法吗?
提前致谢