1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP code

Discussion in 'PHP' started by dean5000v, Jun 7, 2010.

  1. #1
    Hey,

    i made a little quick PHP script for a small hack i needed.

    this is what i come up with, i am always looking to improve my code. Does anyone see a better way to do it?

    			
    <?php
    // Get the current URL and extract the file name 
    function curPageName() {
     $currentPage = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
     if ($currentPage == "index.php"){
     return "1"; 
     } 
     else {
     return "2"; 
      } 
    }
    ?>
    
    
    <?php
    // If the index.php file is open don't include the $menu_box
      if (curPageName()==1){
       }
      else {
      echo $menu_box_header;
      echo '<div id="exp1102170142">';
      echo $menu_box_content;
      echo ' </div>';
       }
    ?>
    Code (markup):

     
    dean5000v, Jun 7, 2010 IP
  2. aniltc

    aniltc Peon

    Messages:
    94
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    use ternary operator in php for 'if loop'
     
    aniltc, Jun 7, 2010 IP