printf()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
niche1
Forum Newbie
Posts: 3
Joined: Fri Oct 01, 2010 2:11 pm

printf()

Post by niche1 »

I have this code that displays properly:

Code: Select all

printf("<p style=\"font-size:9px;margin:0px;\"> <span style=\"background-color:yellow\">Expires %s. </span></p>",$expdat); 
Now, I need to turn the code between in <span> in to a variable with a variable.

How do I code for the second variable in printf() when?:
$dclaim = <span style=\"background-color:yellow\">Expires' . $expdat . '.</span>
Edit/Delete Message
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: printf()

Post by social_experiment »

Code: Select all

<?php
 $expdat = 'Tomorrow';
 $dclaim = "<span style=\"background-color:yellow\">Expires " . $expdat . ".</span>"; 
 printf("<p style=\"font-size:9px;margin:0px;\"> $dclaim </p>", $dclaim);  
?>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply