Jump to content
xisto Community
Sign in to follow this  
Amezis

Question For The If And Echo Function

Recommended Posts

I'm not that good with PHP, and I tried this code:

if ( $_SERVER['REQUEST_URI'] == ('/') )/*'/' is the domain root*/{	echo('<img src="{I_ONEURL}" border="0" alt="{T_SOMETHING}" />');}else{	echo('<img src="{I_ANOTHERURL}" border="0" alt="{T_SOMETHING}" />');}

However, it doesn't work. So, basically, I want that if the request is at the root (actually mysubdomain.domain.com), it will show {I_ONEURL} in the image src. If the request is not at the root, but for instance at index.php?showpage=22, it will show {I_ANOTHERURL} in the image src.

I hope you understand what I want, and can make a new code. And I know I'm not the best PHP programmer :)

Share this post


Link to post
Share on other sites

That should work fine - maybe there's another section of code causing the block you mentioned to not work properly?

 

I wouldn't recommend such a method for what you're trying to do. In my opinion, it would be better to use something like:

 

if( $_SERVER['PHP_SELF'] == '/index.php' && count($_GET) < 1 ) {  // Is the root} else {  // Not the root}

Or:

 

$url = parse_url($_SERVER['REQUEST_URI']);if( ( $url['path'] == '/' || $url['path'] == '/index.php' ) && !isset($url['query']) ) {  // Is the root} else {  // Not the root}

If that makes sense. That's my two dollars worth, anyway.

Share this post


Link to post
Share on other sites

Actually, my code worked.I was using it on a phpBB board, in the template file. I have installed a modification which should allow me to use PHP codes in the phpBB template file. But obviously, I couldn't use the special phpBB template tags IN the PHP code... Well, I thought I did something wrong. Anyways, thanks for your help :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.