Jump to content
php.lv forumi

Printf Un %


CryRat

Recommended Posts

vajadzētu šādu kodu dabūt gatavu

<code><font color="#000000">

echo <TABLE>;
printf("<TR><TD width=25%>%s</TD><TD width=50%>%s</TD><TD width=25%>%s</TD></TR>", $row["ip"], $row["agent"], $row["date"]);
echo </TABLE>;
</font>
</code>

problēma rodas tad kad tiek noradīts "width=25%" jo viņš uzreiz domā ka tas būs kaut kāds mainīgais ( jo "%" ) un tad ar beigās prasa viņu :huh:

 

ko lai gudru izdara ?

 

sorry ja jautājums stulbs esu iesācējs precīzāk tikai dažas dienas nopietni kodēju :ph34r:

Link to comment
Share on other sites

a nevareetu dariit pavisam vienkaarshi ? tb:

<code><font color="#000000">

<font color="#0000CC"><?
</font><font color="#006600">echo </font><font color="#CC0000">"<table><tr>"</font><font color="#006600">;
echo </font><font color="#CC0000">"<td width=25%>"</font><font color="#006600">.</font><font color="#0000CC">$row</font><font color="#006600">[</font><font color="#CC0000">'ip'</font><font color="#006600">].</font><font color="#CC0000">"</td><td width=50%>"</font><font color="#006600">.</font><font color="#0000CC">$row</font><font color="#006600">[</font><font color="#CC0000">'agent'</font><font color="#006600">].</font><font color="#CC0000">"</td><td width=25%>"</font><font color="#006600">.</font><font color="#0000CC">$row</font><font color="#006600">[</font><font color="#CC0000">'date'</font><font color="#006600">].</font><font color="#CC0000">"</td>"</font><font color="#006600">;
echo </font><font color="#CC0000">"</tr></table>"</font><font color="#006600">;
</font><font color="#0000CC">?></font>
</font>
</code>

 

bet ja nu galiigi nevar bez printf() iztikt, tad es domaaju, ka vareetu paliidzeet backlash, ar domu simbols "", kas skaitaas general escape character ... resp naakamais simbols aiz backslasha tiek uzskatiits par parastu simbolu....

 

palabojiet ja kljuudos.... pac arii neesu nekaads specs :)

Link to comment
Share on other sites

<code><font color="#000000">

<font color="#0000CC"><?php
$row</font><font color="#006600">[</font><font color="#0000CC">0</font><font color="#006600">] = </font><font color="#0000CC">[url=http://lv.php.net/getenv]getenv[/url]</font><font color="#006600">(</font><font color="#CC0000">'REMOTE_ADDR'</font><font color="#006600">);
</font><font color="#0000CC">$row</font><font color="#006600">[</font><font color="#0000CC">1</font><font color="#006600">] = </font><font color="#0000CC">[url=http://lv.php.net/getenv]getenv[/url]</font><font color="#006600">(</font><font color="#CC0000">'HTTP_USER_AGENT'</font><font color="#006600">);
</font><font color="#0000CC">$row</font><font color="#006600">[</font><font color="#0000CC">2</font><font color="#006600">] = </font><font color="#0000CC">[url=http://lv.php.net/date]date[/url]</font><font color="#006600">(</font><font color="#CC0000">'dmY'</font><font color="#006600">);
echo </font><font color="#CC0000">"<table><tr>"</font><font color="#006600">;
echo </font><font color="#CC0000">"<td width='25%'>$row</font><font color="#006600">[</font><font color="#CC0000">0</font><font color="#006600">]</font><font color="#CC0000"></td><td width='50%'>$row</font><font color="#006600">[</font><font color="#CC0000">1</font><font color="#006600">]</font><font color="#CC0000"></td><td width='25%'>$row</font><font color="#006600">[</font><font color="#CC0000">2</font><font color="#006600">]</font><font color="#CC0000"></td>"</font><font color="#006600">;
echo </font><font color="#CC0000">"</tr></table>"</font><font color="#006600">;
</font><font color="#0000CC">?></font>
</font>
</code>

Link to comment
Share on other sites

×
×
  • Create New...