Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printef

Status
Not open for further replies.
Hi.
Is possible to include php file inside printf ?
Thank you for help.

Code:
<?php $result = mysql_query("SELECT * FROM base WHERE id='$id' ",$db1);
}
if (mysql_num_rows($result) > 0) {
$myrow = mysql_fetch_array($result); 
do {
printf("
    <table>
        <tr>
            <td>
	       <p>%s</p>
	    </td>
	    <td>
	        <p>[COLOR=red]<?php include ('phpfile.php');?>[/color]</p>
	    </td>
        </tr>
    </table>",$myrow["text"]);
}
while ($myrow = mysql_fetch_array($result));
}
?>
 
Hi

zura said:
Is possible to include php file inside printf ?
Yes, it is. But not that way :
[ul]
[li]PHP tag inside string will not be evaluated. Anyway, not needed.[/li]
[li]Statement inside string will not be evaluated. But you can concatenate its result with string literals.[/li]
[li][tt]include[/tt] only returns what its [tt]return[/tt] statement specifies. Anything else is sent to the output.[/li]
[/ul]
Code:
[COLOR=darkgoldenrod]printf[/color][teal]([/teal][green][i]"[/i][/green]
[green][i]    <table>[/i][/green]
[green][i]        <tr>[/i][/green]
[green][i]            <td>[/i][/green]
[green][i]               <p>%s</p>[/i][/green]
[green][i]            </td>[/i][/green]
[green][i]            <td>[/i][/green]
[green][i]                <p>"[/i][/green][teal].([/teal][red]include[/red] [green][i]'phpfile.php'[/i][/green][teal]).[/teal][green][i]"</p>[/i][/green]
[green][i]            </td>[/i][/green]
[green][i]        </tr>[/i][/green]
[green][i]    </table>"[/i][/green][teal],[/teal][navy]$myrow[/navy][teal][[/teal][green][i]"text"[/i][/green][teal]]);[/teal]
Anyway, do you really need to [tt]include[/tt] that file ? I mean, it really contains PHP code ?

Next time please set your thread's type appropriately. This one is Question, not News.

Feherke.
[link feherke.github.com/][/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top