Questions about programming languages and debugging
sternbildchen
Fame ! Where are the chicks?!
Posts: 421 Joined: 26 Apr 2006, 16:00
17
Location: Germany
Post
by sternbildchen » 12 Jul 2007, 15:05
Code: Select all
<li <?php if(is_home()) { echo 'class="current_page_item"';} ?>><a href="<?php bloginfo('siteurl'); ?>">Blog</a></li>
This is my current code. Now I need a second code to replace
is_home() . Here what it should do:
if (
"current url" starts with http://localhost/wp02/index.php/2007 ) {}
It should also return true if the url is something like
http://localhost/wp02/index.php/2007/07/
I hope someone can help me. I just can't find something that works.
Thanks guys!
shamir
Computer Manager
Posts: 853 Joined: 01 Mar 2007, 17:00
17
Location: NY
Contact:
Post
by shamir » 12 Jul 2007, 15:53
pseudo_opcode
cyber messiah
Posts: 1201 Joined: 30 Apr 2006, 16:00
17
Location: 127.0.0.1
Post
by pseudo_opcode » 13 Jul 2007, 09:04
Code: Select all
if(strpos('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],$url_you_want)==0)
$url_you_want is the url you want to compare with
have fun
sternbildchen
Fame ! Where are the chicks?!
Posts: 421 Joined: 26 Apr 2006, 16:00
17
Location: Germany
Post
by sternbildchen » 13 Jul 2007, 09:36
Thanks pseudo this is what I was searching for!
The bad thing is that it doesn't seem to work for me. Maybe because the server is local? I don't know
always returns true
(f.e. on
http://localhost/wp02/ )
pseudo_opcode
cyber messiah
Posts: 1201 Joined: 30 Apr 2006, 16:00
17
Location: 127.0.0.1
Post
by pseudo_opcode » 13 Jul 2007, 14:10
try this
Code: Select all
if(stripos('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],'http://localhost/wp02/index.php/2007/'))
notice the new function "stripos" and there's no "==0" there,
which version of php you using?
sternbildchen
Fame ! Where are the chicks?!
Posts: 421 Joined: 26 Apr 2006, 16:00
17
Location: Germany
Post
by sternbildchen » 13 Jul 2007, 15:43
PHP Version 5.2.0
I will test out the new code tomorrow. But I will be on vacation for the text three weeks. Thanks for your help! If the code doesn't work I will write something here in three weeks.
/edit: Still doesn't work. Now it always returns false.