Trick to create string with HTML tags in PHP

June 9, 2009

If you are too lazy to perform stripping any kind of  ‘forbidden’ tags in string, like ‘<?’ or ‘ ” ‘ symbol, this is a method:

Example:

<?

$str = <<<EOD
<html><body>
<p>Welcome! Today is the <?php echo(date(‘jS’)); ?> of <?= date(‘F’); ?>.</p>
</body></html>
Text “outside” of the HTML block.
EOD;

echo $str;

?>

It gonna makes your job faster, right? 😉

Advertisements

PHP function to create your own custom YM status

June 9, 2009

This is a quick simple method to create your own custom YM picture status.

Pictures below are just default and ordinary status from Yahoo. Let’s create our own status picture.

Enjoy!

<?

if (!function_exists(getStatusYM)) {
function getStatusYM ($yahoo_id, $user_name, $image_online, $image_offline) {
$pageurl = “http://mail.opi.yahoo.com/online?u=&#8221;.$yahoo_id.”&m=a&t=1″;

$file = @fopen($pageurl, “r”);
$read = @fread($file, 200);
$read = ereg_replace($yahoo_id, “”, $read);

if ($y = strstr ($read, “00”)) {
$online = false;
}
elseif ($y = strstr ($read, “01”)) {
$online = true;
}

@fclose ($file);

echo ‘<div align=”center”><a href=”ymsgr:sendIM?’.$yahoo_id.'”>’;

if ($online) {
echo ‘<img src=”‘.$image_online.'” border=”0″ alt=”‘ . $user_name . ‘ is online” title=”‘ . $user_name . ‘ is online” />’;
}
else {
echo ‘<img src=”‘.$image_offline.'” border=”0″ alt=”‘ . $user_name . ‘ is offline” title=”‘ . $user_name . ‘ is offline” />’;
}

echo ‘</a></div>’;
}
}

getStatusYM (“frozenade”, “Frozenade McForsaken (Webmaster)”, “images/online.png”, “images/offline.png”);

?>