[risolto] Trasformare la seguente classe PHP

Jakub Lemiszewski

Utente Attivo
5 Dic 2013
119
1
0
Salve, ho bisogno di cambiare la seguente classe in modo tale che utilizzi return senza utilizzare gli echo, ma non so come fare. Spero mi aiutiate grazie.
PHP:
<?php
class Page_Data {
   var $title;
   var $keywords;
   var $javascript;
   var $css;
   var $embeddedStyles;
   var $content;

   function Display() { //To display in a page 
     echo "<HTML>\n<HEAD>\n";
     $this->DisplayTitle();
     $this->DisplayKeywords();
     $this->DisplayJavascript();
     $this->DisplayCss();
     $this->DisplayEmbeddedStyles();
     echo "\n</HEAD>\n<BODY>\n";
     echo $this->content;
     echo $this->javascript;
     echo "\n</BODY>\n</HTML>\n";
   }

   function DisplayTitle() {
       $this->title;
   }

   /*function DisplayKeywords() {
      '<META NAME="keywords" CONTENT="' . $this->keywords . '" />';
   }*/
   function DisplayJavascript() {
	 '<SCRIPT TYPE="text/javascript" SRC="js/'. $this->javascript .'"></SCRIPT>';
   } 
   function DisplayCss () {
	 '<LINK HREF="' . $this->css . '" REL="stylesheet" />';
   }
   function EmbeddedStyles () {
	   //-----------//s
   }
   function SetContent( $Data ) {
     $this->Content = $Data;
   }
 }
 
ciao
non sono molto esperto nell'uso delle classi, ma forse puoi provare così
PHP:
<?php
//....
function Display() { //To display in a page 
     $stringa = "<HTML>\n<HEAD>\n";
     $this->DisplayTitle();//queste non devono far parte della stringa ? non sono i tag che devono essere compresi tra <head> e </head>?
     $this->DisplayKeywords();//?
     $this->DisplayJavascript();//?
     $this->DisplayCss();//?
     $this->DisplayEmbeddedStyles();//?
	 $stringa .= "\n</HEAD>\n<BODY>\n".
                 $this->content.
                 $this->javascript.
                 "\n</BODY>\n</HTML>\n";
	 return $stringa;
   } 
//...
?>
al massimo non funziona
 
ciao
non sono molto esperto nell'uso delle classi, ma forse puoi provare così
PHP:
<?php
//....
function Display() { //To display in a page 
     $stringa = "<HTML>\n<HEAD>\n";
     $this->DisplayTitle();//queste non devono far parte della stringa ? non sono i tag che devono essere compresi tra <head> e </head>?
     $this->DisplayKeywords();//?
     $this->DisplayJavascript();//?
     $this->DisplayCss();//?
     $this->DisplayEmbeddedStyles();//?
	 $stringa .= "\n</HEAD>\n<BODY>\n".
                 $this->content.
                 $this->javascript.
                 "\n</BODY>\n</HTML>\n";
	 return $stringa;
   } 
//...
?>
al massimo non funziona

Ciao grazie questo mi ha aiutato :-D
 

Discussioni simili