Generate a phrase to url.

str_replace (PHP 4, PHP 5) str_replace — Replace all occurrences of the search string with the replacement string $vowels = array(“a”, “e”, “i”, “o”, “u”, “A”, “E”, “I”, “O”, “U”); $onlyconsonants = str_replace($vowels, “”, “Hello World of PHP”);

How to write IE specific PHP

if((ereg(“Nav”, getenv(“HTTP_USER_AGENT”))) || (ereg(“Gold”, getenv(“HTTP_USER_AGENT”))) || (ereg(“X11”, getenv(“HTTP_USER_AGENT”))) || (ereg(“Mozilla”, getenv(“HTTP_USER_AGENT”))) || (ereg(“Netscape”, getenv(“HTTP_USER_AGENT”))) AND (!ereg(“MSIE”, getenv(“HTTP_USER_AGENT”)) AND (!ereg(“Konqueror”, getenv(“HTTP_USER_AGENT”))))) $browser = “Netscape”; elseif(ereg(“MSIE”, getenv(“HTTP_USER_AGENT”))) $browser = “MSIE”; elseif(ereg(“Lynx”, getenv(“HTTP_USER_AGENT”))) $browser = “Lynx”; elseif(ereg(“Opera”, getenv(“HTTP_USER_AGENT”))) $browser = “Opera”; elseif(ereg(“WebTV”, getenv(“HTTP_USER_AGENT”))) $browser = “WebTV”; elseif(ereg(“Konqueror”, getenv(“HTTP_USER_AGENT”))) $browser = “Konqueror”; elseif((eregi(“bot”, getenv(“HTTP_USER_AGENT”))) || (ereg(“Google”, getenv(“HTTP_USER_AGENT”))) || (ereg(“Slurp”, […]

Plugin for limit the size of the post in the main page in WordPress

The  plugin  for WordPress in order to control the maximum amount of characters displayed for an entry on the main page. If the set limit is surpassed a link to a page with the whole content will appear and the text on the entry will be chopped to that amount of characters, otherwise the content […]

How to add ads only at the first post?

It is very simple: <?php if ($wp_query->current_post == 0) : ?> <div style=”float:right”> ads come here. </div> <?php endif; ?> If you don’t want the ads show at homepage, using: <?php if (!is_home()) ?>

Sending Email (Text/HTML/Attachments)

Email is the most popular Internet service today. A plenty of emails are sent and delivered each day. The goal of this tutorial is to demonstrate how to generate and send emails in PHP. So, you want to send automated email messages from your PHP application. This can be in direct response to a user’s […]

How to Get the Current Page URL

Sometimes, you might want to get the current page URL that is shown in the browser URL window. For example if you want to let your visitors submit a blog post to Digg you need to get that same exact URL. There are plenty of other reasons as well. Here is how you can do […]

How to usp php to ban ip

First build a database table: CREATE TABLE `su_lockip` (   `id` int(4) NOT NULL auto_increment,   `lockip` varchar(1024) default NULL,   PRIMARY KEY  (`id`) )  Second, design a page so that you can add the ip you want to ban, every ip is devided by |,  I only write the mail part:   $UlockIp=$_POST[‘z’]?$_POST[‘z’]:”;  if(empty($UlockIp)){   […]

List 50 posts of wordpress.

If you want to list 50 posts, use the following code: <ul>  <?php  global $post;  $myposts = get_posts(‘numberposts=-1’);  foreach($myposts as $post) :  ?>     <li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li>  <?php endforeach; ?>  </ul> if you want to list all the posts, use the following codes: <ul>  <?php  global $post;  $myposts = get_posts(‘numberposts=5’);  foreach($myposts as […]

Retrieve a Particular Post or Page

Retrieve a Particular Post <?php // retrieve one post with an ID of 5 query_posts(‘p=5’);      ?> If you want to use the Read More functionality with this query, you will need to set the global $more variable to 0. <?php // retrieve one post with an ID of 5 query_posts(‘p=5’);       global $more; // set […]