[FX.php List] Embed php into HTML or vice versa?

Steve Hannah shannah at sfu.ca
Fri Sep 1 00:14:28 MDT 2006


Normally, using single quotes for HTML is nicer to work with so you  
don't have to escape the double quotes in the html attributes.   
However PHP doesn't process variables inside single quotes so this  
won't work here.  E.g. {$value['City'][0]} will be just printed as  
{$value['City'][0]} and not the associated value.. unfortunately

-Steve
On 31-Aug-06, at 11:00 PM, Gjermund Gusland Thorsen wrote:

> I only use " (double quotes) for \n and \t in php and inside HTML  
> tags,
> this would be my approach;using Hannah's code as starting point:
>
> <?php
> // between <head> and </head>
> foreach( $searchResult['data'] as $key => $value ) {//start for each
> 	list( $currentRecord, $modid ) = explode( '.', $key );
> 	$line[] = '<td>
> 		<a href="famdetail.php?recid={$currentRecord}">{$value 
> ['FamilyName'][0]}</a>
> 		</td>
> 		<td>{$value['StuList'][0]}</td>
> 		<td>{$value['Address1'][0]}</td>
> 		<td>{$value['City'][0]}</td>
> 		<td>{$value['State'][0]}</td>
> 		<td>{$value['Zip'][0]}</td>
> 		<td align="right">
> 		<a href="editfamorder.php?recid={$currentRecord}">
> 		$'.number_format($value['AmtTotal'][0],'2','.','').'
> 		</a>
> 		</td>
> 		<td align="right">
> 		<a href="lunchdetail.php?recid={$currentRecord}">
> 		$'.number_format( $value['LunchTotalPrice'][0],'2','.','').'
> 		</a>
> 		</td>
> 		<td align="center">{'.$value['PTAMembership'][0].'}</td>
> 		</tr>';
> } //end for each
> ?>
>
> // between <body> and </body>
> <?echo '<tr class="ver12">'.implode( '</tr>' . "\n" . '<tr
> class="ver12">', $line ).'</tr>';?>
>
>
> On 9/1/06, Kevin Futter <kfutter at sbc.melb.catholic.edu.au> wrote:
>> On 1/9/06 1:03 PM, "DC" <dan.cynosure at dbmscan.com> wrote:
>>
>> > On Aug 31, 2006, at 10:22 PM, Kevin Futter wrote:
>> >
>> >> The PHP manual itself recommends against them, and they can cause
>> >> all sorts of problems in XML environments, where they can (do)  
>> look
>> >> like an XML prolog.
>> >
>> > True. But, the manual says that you shouldn't use them if you are
>> > developing libraries or code to run on other people's machines. For
>> > your own use on your own systems it is a good tool to have  
>> available
>> > - especially working with web designers.
>> >
>> > According to the PHP manual, your comment about XML also seems to
>> > apply to XHTML though I am not sure why the presence of short PHP
>> > tags in PHP code would make a whit of difference to the validity of
>> > XHTML output by said code. Since you so kindly clarified the most
>> > recent XHTML question would you mind explaining why short tags  
>> would
>> > impinge on XHTML? (I understand the problem with XML)
>> >
>>
>> Well, if you consider that XHTML is technically a reformulation of  
>> HTML as
>> an application of XML, it makes more sense. Most pages that are  
>> marked up as
>> XHTML (even including the correct doctype) are not actually  
>> *served* or
>> *parsed* as XHTML, but as plain ole HTML. Why? Because the only  
>> thing that
>> actually determines whether a document is one or the other is its
>> server-supplied MIME-type header. HTML is served as text/html,  
>> whereas XHTML
>> has a MIME-type of application/xhtml+xml.
>>
>> However, XHTML is almost never served with this MIME-type. Why?  
>> Because IE6
>> and below barf on it. Completely. Hence, the vast majority of the  
>> world's
>> web servers currently deploy text/html for XHTML to avoid this  
>> issue, making
>> most XHTML documents technically not XHTML at all.
>>
>> So, the reason that it appears that short opening tags being  
>> confused for
>> XML prologs has no effect in XHTML is because most of the world's  
>> XHTML
>> pages ... aren't. If they were, you'd see the problem then, for  
>> sure, since
>> technically XHTML requires an XML prolog to pass muster. IE7  
>> purportedly
>> gets this right now, so things will be changing, and there's much  
>> more to
>> deploying XHTML correctly than simple syntax changes.
>>
>> There's more info here for those who are still curious:
>>
>> http://hixie.ch/advocacy/xhtml
>>
>>
>> --
>> Kevin Futter
>> Webmaster, St. Bernard's College
>> http://www.sbc.melb.catholic.edu.au/
>>
>>
>>
>> ------------------------------------------
>> This e-mail and any attachments may be confidential.  You must not  
>> disclose or use the information in this e-mail if you are not the  
>> intended recipient.  If you have received this e-mail in error,  
>> please notify us immediately and delete the e-mail and all  
>> copies.  The College does not guarantee that this e-mail is virus  
>> or error free.  The attached files are provided and may only be  
>> used on the basis that the user assumes all responsibility for any  
>> loss, damage or consequence resulting directly or indirectly from  
>> the use of the attached files, whether caused by the negligence of  
>> the sender or not.  The content and opinions in this e-mail are  
>> not necessarily those of the College.
>>
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>



More information about the FX.php_List mailing list