Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Zasto ispisuje vrednosti i kljuvceve niza u definiciji niza?

[es] :: PHP :: Zasto ispisuje vrednosti i kljuvceve niza u definiciji niza?

[ Pregleda: 1335 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

voxi

Član broj: 67178
Poruke: 328
*.skaut.net.



Profil

icon Zasto ispisuje vrednosti i kljuvceve niza u definiciji niza?20.04.2007. u 15:57 - pre 207 meseci
Evo kod i nije mi jasno kada pozovem ovu klasu i metodu Display() urdi se sve dobro samo uporno ispisuje vrednosti i kljuceve na html stranici. Upitanju je niz $buttons?

stvarno mi nije jasna ova stvar



Code:

<?php
class Page{
    //atributi klase Page;
    public $content;
    public $title='TLA Consulting Pty Ltd';
    public $keywords='TLA Consulting, Three Letter Abbreviation some of my best friends are search endiges';
     public $buttons=array('Home'    => 'home.php',
                         'Contact' => 'contact.php', 
                         'Services' => 'services.php',
                         'Site Map' => 'map.php');
                        
                        
  public $bt=array('23','2321','4');
    
    public function Display(){
         echo "<html>\n  <head>\n" ;
         
       //echo "Velicina niza ".count($this->buttons)."\n";
       //echo "Velicina niza ".count($this->bt)."\n";
       $this->DisplayTitle();
       $this->DisplayKeywords();
       $this->DisplayStyles();
       
       echo "</head>\n<body>";
       $this->DisplayHeader();
       $this->DisplayMenu($buttons);
        echo "</body> \n </html>";         
  }
     

 
  public function __set($name,$value){
    
       $this->$name=$value;
      
  }

  public function DisplayTitle(){  
      echo '<title>'.$this->title.'</title>';  
  }
  
  public function DisplayKeywords(){
  
      echo "<meta name=\"keewords\" content=\"".htmlentities($this->keywords)."\" />";
  }
  
  public function DisplayStyles(){
  ?>
  <style>
  <!--
    td{background:black}   
    p{color:black; font-size:12pt; text-aligne:justify; font-family:arial;,sans-serif}
    p.foot{color:white; font-size:9pt; text-aligne:center; font-family: arial, sans-serif}
    a:link, a:visited, a:active{color:white}
    
  -->  
   </style> 
    
  <?php
  }
  
  public function DisplayHeader(){
  ?>
      <table width"100" cellpadding="12" cellspacing="0" border="0">
            <tr bgcolor="black">
                <td aligne="left">  <img src="slk/logo.gif">   </td>
                <td> 
                    <h1> TLA Consulting Pty Ltd <h1>
                </td>
                
                <td aligne="right" > <img src="slk/logo.gif"> </td>
            </tr>    
     </table>
  
  <?php           
  } 
  
  public function DisplayMenu($buttons){
  
      echo "<table width='100%' bgcolor='white' cellpadding='4' cellspacing='4'";
      echo "<tr>\n";
      //izracunavanje velicine dugmeta
      $width=100/count($this->buttons);
      
       foreach ($this->buttons as $name=>$url)
          $this-> DisplayButton($width, $name, $url, !$this->IsURLCurrentPage($url));
    
       echo "</tr>\n";
       echo "</table>\n";
   }
   
   public function IsURLCurrentPage($url){
   
          echo 'Urls='.$url.'';
          if(strpos($_SERVER['PHP_SELF'],$url)==false){          
              return false;          
          }
          else{
              return true;          
          } 
   
   }
      
   
   public function DisplayButton($width, $name, $url, $active=true){
        
        if($active)
            {
                echo "<td width='".htmlentities($width)."%'> 
                      <a href='".htmlentities($url)."'>
                <img src='slk/s-log.gif' alt='".htmlentities($name)."' border='0'></a>
                      <a href='".htmlentities($url)."'> <span class='menu'>$name</span></a></td>";                 
            }
        else{
        
            echo "<td width='".htmlentities($width)."%')>
                  <img src='slk/side-logo.gif'>
                  <span class='menu'> $name</span> </td>";
             
        }
     }
     
     public function DysplayFooter(){
        
        ?>
            <table width="100%" bgcolor="black" cellpadding="12" border="0"> 
                <tr>
                    <td>
                        <p class="foot"> &copy; TLA Consulting Pty Ltd. </p>
                        <p class="foot"> Please see our <a href="legal.php"> legal information page,</a> </p>
                        
                    
                    </td>
                
                </tr>
            
            </table>
        <?php
        
        }  
  
 }
?>



eevo i koda iz koje pozivam klasu Page i medotu Display()


Code:

<?php
  require('Page.php');
  
  $pg=new Page(); 
  
  $pg->Display();
?>


 
Odgovor na temu

VladaSu

Član broj: 31634
Poruke: 1099
77.46.159.*



+218 Profil

icon Re: Zasto ispisuje vrednosti i kljuvceve niza u definiciji niza?06.07.2007. u 17:42 - pre 204 meseci
Pozvao si:
$pg->Display();

a u ovoj funkciji imas:
$this->DisplayMenu($buttons);

a tamo imas:
$this-> DisplayButton($width, $name, $url, !$this->IsURLCurrentPage($url));

i tu ispisujes $button array
[Ovu poruku je menjao VladaSu dana 14.06.2003. u 11:22 GMT+1]
 
Odgovor na temu

[es] :: PHP :: Zasto ispisuje vrednosti i kljuvceve niza u definiciji niza?

[ Pregleda: 1335 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.