<?php
//generate random string with 20 characters (you can change the 20 to whatever number)
//the shorter you have this string, the more likely you will have two strings that are repeated
//to be safe, i would have this at least 20
$rand = substr(md5(microtime()),rand(0,26),20);
//generate random letter
$letter = chr(rand(64, 90));
//echo it out, $letter has to go first since classes and ids must start with a letter
echo $letter , $rand;
//okay so now we understand how it all works, let's apply it to an ad
//let's create our "ad"
echo '<style type="text/css">
.' , $letter, $rand , ' {
height: auto;
width: auto;
max-width: 100px;
border: 2px outset #000;
background-color: red;
overflow: auto;
text-align: center;
padding: 20px;
}
</style>';
//okay now our "ad" is made in the CSS, let's output it
echo '<div class="' , $letter, $rand , '">This is your ad.</div>';
//this example is only for one ad. if you want to use this for multiple ads, you'll have to generate a new $rand string.
//you can reuse the $letter, but don't reuse both or you'll have multiple ads with the same class and it won't look right.
//it may not look like anything is really happening to the front-end user, but that's because everything is happening
//before the page even loads. This way, even if they block the element, the next time they load the page, it will
//be right back again with a new name. :^) enjoy ~JBG
?>
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.