我有一个具有以下结构的变量:
$catname = 'this-is-my-category';
Run Code Online (Sandbox Code Playgroud)
如何去除“-”并得到:
$catname = 'this is my category';
Run Code Online (Sandbox Code Playgroud) 知道如何使这项工作?
$title = wp_title();
问题是wordpress会自动回应 wp_title();
有任何想法吗?
嘿那里,我有这个变量:
<?php $blog_description = get_bloginfo('description'); ?>
$blog_description ='I am a text, I have commas, and periods. And I want the text without them';
Run Code Online (Sandbox Code Playgroud)
如何从$ blog_description中提取逗号和句点?我想在我的网站标题中将其用作元描述.
我有这个简单的代码:
哪个更好,用esleif做或做两个单独的ifs?
if(is_home() && $currentpage == ''){
$catname = 'cars';
} elseif(is_home() && $currentpage != '' && is_page_template('models.php')){
$catname = 'newcars';
}
Run Code Online (Sandbox Code Playgroud)
两个separete if条款:
if(is_home() && $currentpage == ''){
$catname = 'cars';
}
if(is_home() && $currentpage != '' && is_page_template('models.php')){
$catname = 'newcars';
}
Run Code Online (Sandbox Code Playgroud)
这个顺序是否重要?我可以先放第二个吗?问题应该是php如何处理从更具体到更一般的条件?你应该总是从更具体的那些开始,一路走向一般吗?或者php可以对它们进行排序?
第二个版本对我来说会更容易,因为我有分配的if :)
我试图创建一个功能,削减字符串中的空格和广告标点符号,如果没有.
这是我的测试字符串:
$test = 'Hey there I am traa la la ';
Run Code Online (Sandbox Code Playgroud)
我希望它变成这样:
$test = 'Hey there I am traa la la.';
Run Code Online (Sandbox Code Playgroud)
这是我尝试过的功能:
function test($mytrim){
for($i = 0; $i <= 5; $i++){
if(substr($mytrim, 0, -1) == ''){
$mytrim = substr($mytrim, 0, -1);
}
}
$punct = array(".",",","?","!");
if(!in_array($mytrim, $punct)){ $mytrim .= '.'; }
return $mytrim;
}
Run Code Online (Sandbox Code Playgroud)
它返回:
$mytrim = 'Hey there I am traa la la. .';
Run Code Online (Sandbox Code Playgroud)
任何想法为什么它不起作用?
我使用 preg Replace 通过在每组三位数之间插入空格来分隔数字:
$alexa_rank_raw = 8389876;
$alexa_rank = preg_replace("/(\d{3})/", '$1.', $alexa_rank_raw);
// alexa rank becomes: 838.987.6
Run Code Online (Sandbox Code Playgroud)
我该如何进行替换,最终的数字将如下所示:
8.389.876
有任何想法吗?
嘿那里,我已经安装了wordpress多站点和域映射插件.
问题是与www ...如果我设置多站点没有www和我访问网站没有www一切正常但如果我访问它没有www,它reddirects到主站点.任何想法为什么?泰
我有这种CSS风格:
background:#000;
background:rgba(0,0,0,0.7);
background: transparent;
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#B2000000,endColorstr=#B2000000)"; /* IE8 */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#B2000000,endColorstr=#B2000000); /* IE6 & 7 */
zoom: 1;
Run Code Online (Sandbox Code Playgroud)
它在Internet Explorer中运行良好,但我必须保持背景:透明; 样式.如果我保留它,mozilla使我的背景透明
任何想法?
我有一个javascript代码来重定向手机用户.你能检查一下代码吗,我已经从网上拿到了它,总数是新的,我会重视你对脚本质量的看法......
它涵盖所有类型的手机吗?
function RedirectSmartphone(url) {
if (url && url.length > 0 && IsSmartphone())
window.location = url;
}
function IsSmartphone() {
if (DetectUagent("android")) return true;
else if (DetectUagent("iphone")) return true;
else if (DetectUagent("ipod")) return true;
else if (DetectUagent("symbian")) return true;
return false;
}
function DetectUagent(name) {
var uagent = navigator.userAgent.toLowerCase();
if (uagent.search(name) > -1)
return true;
else
return false;
}
RedirectSmartphone("http://mobile.version.com");
Run Code Online (Sandbox Code Playgroud) 我有一个js.js脚本来处理我所有的jQuery函数.文档就绪后我逐个称呼它们,如下所示:
function 1(){}
function 2(){}
jQuery(document).ready(function($){
function 1();
function 2();
});
Run Code Online (Sandbox Code Playgroud)
我还有一个外部JavaScript,我在我的网站标签内调用:
<script type="text/javascript" src="myscript"></script>
Run Code Online (Sandbox Code Playgroud)
这个脚本的问题是它从外部网站加载,有时非常慢,减慢了我的整个网站.
文件准备好之后,我可以将它加载到我的js.js文件中吗?让我们说功能2()之前?
有任何想法吗?
我正在做这个重定向:
$perf = get_query_var('goperf');
$campaignid = get_option('campaign_id');
$url = 'http://ww.mysite.com?test=1&testtwo=2';
header("HTTP/1.1 301 Moved Permanently");
header('Location: '.$url);
exit;
Run Code Online (Sandbox Code Playgroud)
我应该使用:
$url = 'http://ww.mysite.com?test=1&testtwo=2';
Run Code Online (Sandbox Code Playgroud)
或者我应该编码&?使用&而不是&
$url = 'http://ww.mysite.com?test=1&esttwo=2';
Run Code Online (Sandbox Code Playgroud)
TY
我在里面有以下php代码 我网站的一部分.
这是一个非常简单的代码,它添加了元名称机器人,wmt工具验证元和rss元.
它工作正常,但有一点:
当我使用IE或Fireforx查看我的页面源时,我看不到元之间的新行.它们在一行上一个接一个地显示.
如何添加新行?有任何想法吗?如果我让他们这样,会有任何问题吗?
这是代码:
if((is_home() && $currentpage == 1) || (is_single() && $title != 'Online' && $title != 'Cam') || (is_category() && $robots == 'y')){
echo '<meta name="robots" content="index,follow"/>';
} else {
echo '<meta name="robots" content="noindex,follow"/>';
}
if(get_option('enable_wmt') == 'y'){
echo '<meta name="google-site-verification" content="'.get_option('wmt').'"/>';
}
if (is_home() && $currentpage == 1){
echo '<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="'.$site_current.'/feed/"/>';
}
Run Code Online (Sandbox Code Playgroud)