Parse error: syntax error, unexpected $end in
Résolu/Fermé
fifouta
Messages postés
12
Date d'inscription
vendredi 20 juin 2008
Statut
Membre
Dernière intervention
14 février 2012
-
20 juin 2008 à 01:31
fifouta - 20 juin 2008 à 18:51
fifouta - 20 juin 2008 à 18:51
A voir également:
- Parse error: syntax error, unexpected $end in
- Cmos checksum error ✓ - Forum Carte-mère/mémoire
- Fan error lenovo - Forum Refroidissement
- Error 10 pioneer ✓ - Forum Autoradio
- Playback error reconnect in 3s (1/5) francais - Forum Box et Streaming vidéo
- Whea error occt - Forum Processeur
1 réponse
Ton code est vraiment très "sale", je te conseille à l'avenir d'écrire tout en php et de pas ouvrir toutes les dix lignes des balises php, du genre à la fin <?php } } ?> !!!
Enfin bon, voici le code corrigé à partir de la fonction displaybutton :
public function displaybutton($width, $name, $url, $active= true)
{
if ($active)
{
echo "<td width ='".htmlentities($width)."%'>\
<a href ='".htmlentities($url)."'>\
<img src ='s-logo.gif' alt= '".htmlentities($name)."' border ='0' /></a>\
<a href ='".htmlentities($url)."'><span class='menu'> $name</span>\
</a></td>";
}
else
{
echo "<td width ='".htmlentities($width)."%'>";
echo "<img src ='side-logo.gif'>\
<span class='menu'>$name</span></td>";
}
}
public function displayfooter()
{
?>
<table width =\"100%\" bgcolor =\"black\" cellpadding =\"12\" border =\"0\">
<tr>
<td>
<p class=\"foot\">© TLA consulting pty Ltd .</p>
<p class=\"foot\">please see our <a href =\"legal.php\">legal information page </a></p>
</td>
</tr>
</table>
<?php
}
}
?>
Enfin bon, voici le code corrigé à partir de la fonction displaybutton :
public function displaybutton($width, $name, $url, $active= true)
{
if ($active)
{
echo "<td width ='".htmlentities($width)."%'>\
<a href ='".htmlentities($url)."'>\
<img src ='s-logo.gif' alt= '".htmlentities($name)."' border ='0' /></a>\
<a href ='".htmlentities($url)."'><span class='menu'> $name</span>\
</a></td>";
}
else
{
echo "<td width ='".htmlentities($width)."%'>";
echo "<img src ='side-logo.gif'>\
<span class='menu'>$name</span></td>";
}
}
public function displayfooter()
{
?>
<table width =\"100%\" bgcolor =\"black\" cellpadding =\"12\" border =\"0\">
<tr>
<td>
<p class=\"foot\">© TLA consulting pty Ltd .</p>
<p class=\"foot\">please see our <a href =\"legal.php\">legal information page </a></p>
</td>
</tr>
</table>
<?php
}
}
?>
20 juin 2008 à 12:29
merci bob pour ta réponse , en ce qui concerne le code , je l'ai copié à partir d'un livre et étant novice dans la programmation php d'un coté et programmation OO de l'autre , il m'est difficile de distinguer les erreurs mais je vais y remédier c'est juste une question de temps.
dans cet exemple , on vous explique l'héritage, création de classe et instanciation de cette dernière d'une façon trés simple.
revenons à nos moutons , finalement c'était un problème de double quotes et de points virgule !! , mais il reste juste un petit souci , c'est qu'à l'affichage je remarque cette ligne qui ne devrais pas etre affichée :
keywords)."\" />
je vous donne l'exemple au complet : le fichier page.inc et home.php , ce dernier fichier crée un objet à partir de la classe page cet objet n'est rien que la page d'accueil .
page.inc
<?php
class page
{
//attributs de la classe page
public $content;
public $title = 'TLA consulting Pty Ltd ';
public $keywords = 'TLA consulting ,Three letter abreviation, some of my best friends are search engines ';
public $buttons = array( 'Home' => 'home.php' ,
'contact' => 'contact.php',
'services' => 'services.php',
'site map' => 'map.php' );
//opérations de la classe page
public function __set($name, $value)
{
$this->$name = $value;
}
public function display()
{
echo "<html>\n<head>\n";
$this ->displaytitle();
$this ->displaykeywords();
$this ->displaystyles();
echo "</head>\n<body>\n";
$this ->displayheader();
$this ->displaymenu($this->buttons);
echo $this->content;
$this -> displayfooter();
echo "</body>\n</html>\n";
}
public function displaytitle()
{
echo '<title> '.$this ->title.'</title>';
}
public function displaykeywords()
{
echo '<meta name=\"keywords\" content= \
"".htmlentities($this ->keywords)."\" />'; /// le problème est là !!!!
}
public function displaystyles ()
{
?>
<style>
<!--
h1 {color:white;font-size:24pt; text-align;center;
font-family;arial, sans-serif}
.menu {color:white; font-size:12pt; text-align:center;
font-family:arial,sans-serif; font-weight:bold}
td {background :black}
p {color:white; font-size:12pt; text-align: center;
p.foot {color: white; font-size:9pt; text-align: center;
font-family: arial,sans-serif; font-weight:bold}
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 align ="left"><img src = "hand.png" /></td>
<td>
<h1>TLA consulting pty Ltd </h1>
</td>
</tr>
</table>
<?php
}
public function displaymenu($buttons)
{
echo "<table width ='100%' bgcolor ='white' cellpadding ='4' cellspacing ='4'>\n" ;
echo "<tr>\n";
//calculer la taille des boutons
$width =100 /count ($buttons);
foreach ($buttons as $name=> $url)
{
$this ->displaybutton($width, $name, $url, !$this->isurlcurrentpage($url));
}
echo "</tr>\n";
echo "</table>\n";
}
public function isurlcurrentpage($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 ='user.png' alt= '".htmlentities($name)."' border ='0' /></a>\
<a href ='".htmlentities($url)."'><span class='menu'> $name</span>
</a></td>";
}
else
{
echo "<td width ='".htmlentities($width)."%'>";
echo "<img src ='home.png'>\
<span class='menu'>$name</span></td>";
}
}
public function displayfooter()
{
?>
<table width =\"100%\" bgcolor =\"black\" cellpadding =\"12\" border =\"0\">
<tr>
<td>
<p class=\"foot\">© TLA consulting pty Ltd .</p>
<p class=\"foot\">please see our <a href =\"legal.php\">legal information page </a></p>
</td>
</tr>
</table>
<?php
}
}
?>
et voici le fochier home.php
<?php
require ('page.inc');
$homepage = new page();
$homepage -> content ='<p> welcome to the home of TLA consulting .
please take some time to get to know us .</p>
<p> we specialize in serving your business needs and hope to hear from you soon .</p>';
$homepage ->display();
?>
merci d'avance
20 juin 2008 à 15:13
La solution est là :
public function displaykeywords()
{
echo '<meta name="keywords" content="'.htmlentities($this ->keywords).'" />';
}
20 juin 2008 à 18:51