Mammouth du PHP |
19672 Messages
14 nov. 2005, 22:09
La premièr chose à faire, ce sont des concaténations propres: on ne mélange pas n'importe comment du HTML et du PHP. Suggestion, j'ai déplacé le test de contrôle en haut où il a plus sa place et défini une nouvelle variable :
<?php
/* Routine pour la visibilité du tel portable*/
$voir_port = '- Tel portable<span>'. $tel_indic . '-' . $tel_port . '</span><br>'."\r\n";
$cache_port = '<span style="display:none;"></span>';
$port = empty($tel_port) ? $cache_port : $voir_port;
$corps_prof = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">'."\r\n";
$corps_prof .= '<html>'."\r\n";
$corps_prof .= '<head>'."\r\n";
$corps_prof .= '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'."\r\n";
$corps_prof .= '<title>mon site </title>'."\r\n";
$corps_prof .= '<style type="text/css">'."\r\n";
$corps_prof .= '<!--'."\r\n";
$corps_prof .= 'body{'."\r\n";
$corps_prof .= ' margin:0;'."\r\n";
$corps_prof .= ' font-family: Georgia, "Times New Roman", Times, serif;'."\r\n";
$corps_prof .= ' font-size: 1em;'."\r\n";
$corps_prof .= ' }'."\r\n";
$corps_prof .= '#cont{'."\r\n";
$corps_prof .= ' width: 700px;'."\r\n";
$corps_prof .= ' margin-right: auto;'."\r\n";
$corps_prof .= ' margin-left: auto;'."\r\n";
$corps_prof .= ' padding-top: 1em;'."\r\n";
$corps_prof .= '} '."\r\n";
$corps_prof .= '#cont h2{'."\r\n";
$corps_prof .= ' width: 100%;'."\r\n";
$corps_prof .= ' text-align: center;'."\r\n";
$corps_prof .= ' text-decoration: underline;'."\r\n";
$corps_prof .= '}'."\r\n";
$corps_prof .= '#cont p{'."\r\n";
$corps_prof .= ' width: 100%;'."\r\n";
$corps_prof .= ' text-align: justify;'."\r\n";
$corps_prof .= '}'."\r\n";
$corps_prof .= '#cont span{'."\r\n";
$corps_prof .= ' color: #0000CC;'."\r\n";
$corps_prof .= '}'."\r\n";
$corps_prof .= '-->'."\r\n";
$corps_prof .= '</style>'."\r\n";
$corps_prof .= '</head>'."\r\n";
$corps_prof .= '<body>'."\r\n";
$corps_prof .= ' <div id="cont">'."\r\n";
$corps_prof .= ' <h2>mon site, '. $email_13 .'</h2>'."\r\n";
$corps_prof .= ' <p>eurosite<span>®</span><br>'."\r\n";
$corps_prof .= ' rue du bois<br>'."\r\n";
$corps_prof .= ' 65000 machin</p>'."\r\n";
$corps_prof .= ' <p>Tel: 0033 - Ø3 87 85 66 68<br>'."\r\n";
$corps_prof .= ' Fax: 0033 - Ø3 87 85 69 39<br>'."\r\n";
$corps_prof .= ' Email: [email protected]</p>'."\r\n";
$corps_prof .= ' <p> </p>'."\r\n";
$corps_prof .= ' <p>'. $mail_1 .' '. $titre .' <span>'. $nom .' '. $prenom .'</span></p>'."\r\n";
$corps_prof .= ' <p>'. $mail_2 .' '. $date_envoi .', '. $mail_3 .'<span>"'. $genre[0] .' '. $genre[1] .' '. $genre[2] .' '. $genre[3] .'"</span> '. $mail_4 .' <br>'."\r\n";
$corps_prof .= ' '. $mail_5 .' <span>'. $nb_ligne .'</span> '. $mail_6 .' <span>" '. $sens_a .'-'. $sens_b .' "</span>'. $mail_7 .' <span>'. $day .' '. $moi .' '. $annee .'</span>.</p>'."\r\n";
$corps_prof .= ' <p>'. $mail_8 .'<br>'."\r\n";
$corps_prof .= ' - '. $mail_9 .' <span>'. $tel_indic .' - '. $tel_fixe .'</span><br>'."\r\n";
$corps_prof .= ' '. $port .'- E-mail : <span>'. $email .'</span></p>'."\r\n";
$corps_prof .= ' <p>'. $mail_10 .'</p>'."\r\n";
$corps_prof .= ' <p>'. $mail_11 .'</p>'."\r\n";
$corps_prof .= ' </div>'."\r\n";
$corps_prof .= '</body>'."\r\n";
$corps_prof .= '</html>'."\r\n";
echo($corps_prof);
?>
Comme tu peux voir, j'ai créé une variable $port que j'ai mis à la place de ton test au milieu du code, déplacé le test en haut, et à l'arrivée, la valeur de la variable est de toutes façon définie au moment de t'en servir.
Codez en pensant que celui qui maintiendra votre code est un psychopathe qui connait votre adresse 