Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Question For The If And Echo Function
Amezis
post Dec 3 2005, 09:54 PM
Post #1


Privileged Member
*********

Group: Members
Posts: 535
Joined: 14-February 05
From: Oslo, Norway
Member No.: 3,759



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

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 tongue.gif
Go to the top of the page
 
+Quote Post
Spectre
post Dec 4 2005, 06:07 AM
Post #2


Privileged Member
*********

Group: Members
Posts: 873
Joined: 30-July 04
Member No.: 246



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:

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


Or:

CODE
$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.
Go to the top of the page
 
+Quote Post
Amezis
post Dec 4 2005, 08:33 AM
Post #3


Privileged Member
*********

Group: Members
Posts: 535
Joined: 14-February 05
From: Oslo, Norway
Member No.: 3,759



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 smile.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Getting List Of Directories And Files Using Php(6)
  2. Need Feedback On A Function(1)
  3. Directory Function(1)
  4. Error When Using file_put_contents()(4)
  5. Sending Attachments Using Email Function In Php(2)
  6. Need Help With The Header() Function(2)
  7. Need Help With Php(2)
  8. php header() function help needed(4)
  9. How To Use A Link To Call Function In Php?(8)
  10. Include File.php?id=something(13)
  11. Complex Php Echo Statement Assistance(3)
  12. How To Enable Mail() Function In Php(1)
  13. Question About The Mail() Function(2)
  14. Regexp Function Preg_match_all()(0)
  15. Explode Function Help(1)
  1. How Good Is This Data Cleaning Function?(2)
  2. The Extract() Function(6)
  3. Error With Joomla Template(1)
  4. [php] Header Function(2)
  5. [php](simple) Using Functions To Combine Values In A Form(2)
  6. Mail() Clone(5)
  7. The Best Zip Function(1)
  8. Php Explode Function Help(4)
  9. How To Check If Fsockopen Function Is Enabled?(2)
  10. Arrays Outside A Function(3)
  11. Endif function?(6)
  12. Need Help With Php Echo(2)
  13. PHP Function To Add Previous and Next Page Feature(5)


 



- Lo-Fi Version Time is now: 13th October 2008 - 10:30 PM