Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: generatelink() ? :|
Forum PHP.pl > Forum > Przedszkole
b4x
  1. <? $links = new generatelink(5); echo '<a href="'.$links[url].'">'.$links[name].'</a>'; ?>


Jak powinna wygladac funkcja do tego ? :]
FanFataL
Cytat(b4x @ 2006-01-25 16:31:07)
  1. <? $links = new generatelink(5); echo '<a href="'.$links[url].'">'.$links[name].'</a>'; ?>


Jak powinna wygladac funkcja do tego ? :]

  1. <?php
  2. function generatelink() {
  3. return array('url'=>'http://pl.php.net/manual/pl/', 'name'=>'Czytaj manual !!');
  4. }
  5.  
  6. $links = generatelink(5);
  7. echo '<a href="'.$links[url].'">'.$links[name].'</a>';
  8. ?>
.:dR@kE:.
To zależy co chcesz zrobić?
b4x
Aby sie generowały linki typu nazwa-011.php bo w .htaccess wiem jak zmienic na .html tongue.gif to z tym problemu nie bedzie ;P
Tylko jak generowac linki tongue.gif
np po 5
jaco
Cytat(FanFataL @ 2006-01-25 18:37:56)
Cytat(b4x @ 2006-01-25 16:31:07)
  1. <? $links = new generatelink(5); echo '<a href=\"'.$links[url].'\">'.$links[name].'</a>'; ?>


Jak powinna wygladac funkcja do tego ? :]

  1. <?php
  2. function generatelink() {
  3.     return array('url'=>'http://pl.php.net/manual/pl/', 'name'=>'Czytaj manual !!');
  4. }
  5.  
  6. $links = generatelink(5);
  7. echo '<a href="'.$links[url].'">'.$links[name].'</a>';
  8. ?>

  1. <?php
  2. function generatelink() {
  3. define('url', 0);
  4. define('name', 1);
  5.     return array('http://pl.php.net/manual/pl/', 'Czytaj manual !!');
  6. }
  7.  
  8. $links = generatelink(5);
  9. echo '<a href="'.$links[url].'">'.$links[name].'</a>';
  10. ?>


tongue.gif
Vengeance
  1. <?php
  2. class GenerateLink
  3. {
  4.  private $anachor, $url;
  5.  
  6.  public function __construct($id)
  7.  {
  8. $this->anachor = "Link $id";
  9. $this->url = 'http://www.stanowski.info';
  10.  }
  11.  
  12.  public function __toString()
  13.  {
  14. return '<a href="'. $this->url .'">'. $this->anachor .'</a>';
  15.  } 
  16. }
  17.  
  18. $link = new generatelink(5);
  19. echo $link;
  20. ?>


Rotfl ;]
b4x
Cytat(Vengeance @ 2006-01-25 16:44:50)
  1. <?php
  2. class GenerateLink
  3. {
  4.  private $anachor, $url;
  5.  
  6.  public function __construct($id)
  7.  {
  8. $this->anachor = "Link $id";
  9. $this->url = 'http://www.stanowski.info';
  10.  }
  11.  
  12.  public function __toString()
  13.  {
  14. return '<a href="'. $this->url .'">'. $this->anachor .'</a>';
  15.  } 
  16. }
  17.  
  18. $link = new generatelink(5);
  19. echo $link;
  20. ?>
  21.  
  22. Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUN
    CTION or T_VAR or '}' in 45



Rotfl ;]

Erorrr
Vengeance
Bo to zadziała wyłącznie na php5
b4x
A na php3 czy tam 4 ?
mike
  1. <?php
  2. class GenerateLink
  3. {
  4.  var $anachor;
  5.  var $url;
  6.  
  7.  function GenerateLink($id)
  8.  {
  9. $this->anachor = "Link $id";
  10. $this->url = 'http://www.stanowski.info';
  11.  }
  12.  
  13.  function toString()
  14.  {
  15. return '<a href="'. $this->url .'">'. $this->anachor .'</a>';
  16.  } 
  17. }
  18.  
  19. $link = new GenerateLink(5);
  20. echo $link->toString();
  21. ?>
b4x
tylko 1 generuje i ten sam biggrin.gif
A ma generowac po 5 i kazdy inny :}
PUPI
  1. <?php
  2. class GenerateLink
  3. {
  4.  var $links;
  5.  var $url;
  6.  
  7.  function GenerateLink($links)
  8.  {
  9. $this->links = $links;
  10. $this->url = 'http://www.stanowski.info';
  11.  }
  12.  
  13.  function toString()
  14.  {
  15. $string ='';
  16. for ($i=1;$i<=$this->links;$i++)
  17. {
  18. $string .= '<a href="'. $this->url .'">Link '. $i .'</a><br/>';
  19. }
  20. return $string;
  21.  } 
  22. }
  23.  
  24. $link = new GenerateLink(5);
  25. echo $link->toString();
  26. ?>
winksmiley.jpg
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.