Tag Archives: PHP


Easy PHP I: Introduction


I’ve been involved with PHP since I got into the web design and development world. This is because since in my beginnings I chose to use WordPress as a CMS to build websites with and since that day I have been needing PHP to build WordPress themes (and plug-ins lately). I have learned a lot of PHP tips and tricks, but I have not yet been able to study it regularly and eventually an advanced programmer as I aim. Hence I would love to be fluent in PHP and I know that it would open a whole new business world in front of me. So, in order to push myself into the academical learning process, I will be writing down my learning experience into tutorials. In this way I hope to kill two birds with one stone: learn deeper PHP for myself and let others learn faster and hopefully better through these tutorials too. So, let’s get the hands dirty.

What the Heck is PHP

To get started we need to know what we are talking about. There are two different opinions as where PHP derives from. The first one tells us it stands for “Personal Home Page Tools” and the second one stands for “Hypertext Preprocessor”. No matter where it derives as a acronym, PHP is server-side programming language. It is the one responsible for taking our requests to the server and bringing to us what the server gives it. PHP can be embedded within your HTML and vice versa which is something that makes it a great language. PHP file extension end in “.php”. PHP supports a ton of databases such as: MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc, but it seems to have chosen the first one, MySQL, to marry with. The last but not the least, PHP is an open source software and is free to download and use.

Why Should I Use PHP

PHP is free, open source and has a great community after it. PHP is now mature and can fulfill your every wish. Furthermore, it’s aimed for the web and it gets to work done. PHP is compatible with almost all servers used today (Apache, IIS, etc.) and almost every hosting company offers PHP enabled web hosting service. PHP is also easy and fun to learn as these tutorials will prove it. Moreover, PHP is so popular that if you’re looking for a career in the web design/web development industry then you just have to know it. Final word: it has proven itself over the years to be one of the best options for dynamic web applications.

Am I Ready to Learn PHP

Off course you are! However, you need to have a basic understanding of (X)HTML. That is all you need. However, knowing some JavaScript and CSS would make the situation a lot more fun.

How to Start with PHP

You need a developing environment to write and run PHP code. Basically you need to have Apache Server, MySQL and PHP installed on your computer. You can install them separately, but it is not a wise go. The best option to start with whether you are a Linux, Mac, Windows or even Solaris user is XAMPP. XAMPP is a compilation of Apache server, MySQL and PHP and a bunch of other applications like PHPMyAdmin, all-in-one. As I mentioned, it is cross-platform and really easy to use. I use it myself and I love it. You can download at ApacheFriends.org. However, there are other options that you can consider like : WAMP specifically for Windows found at WampServer.com. MAMP specifically for Mac found at Mamp.info. Pick and choose!

Basic PHP Syntax

A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code. Below, we have an example of a simple PHP script which sends the text “PHP is cool, right?” to the browser:

<?php echo "PHP is cool, right?"; ?>

Each code line in PHP must end with a semicolon (;). The semicolon is a separator and is used to distinguish one set of instructions from another. Also, as you can see the text is wrapped with double quotes. We can use single quotes in its place too. There is a slight difference between double and single quotes that we are going to discuss in the next tutorial. Also, there are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text “My PHP Script”. Note: The file must have a .php extension. If the file has a .html extension, the PHP code will not be executed.

Comments in PHP

Commenting your code is a programming virtue. It is a practice of best programmers and one of principles of programming engineering. Commenting your code helps you to understand what you have been writing in the past as you might forget programming tricks and functions once in a while, also, it help others to expand and improve your code easily. So, always comment your code.

In PHP, we use // and # to make a single-line comment or /* and */ to make a multi-line comment block. Have a look at the example below.


//This is a single line comment 

#This is a singe line comment too 

/* This is a comment block. 
Works the same way as commenting
 CSS code. */ ?>


This is how PHP looks like, but this is only the first step. To learn more fun things about PHP, read the next tutorial. Note: If the tutorial name does not have an active link, it means it is not posted yet, so stay tuned.

What is next:

  • PHP Introduction
  • PHP Variables
  • PHP Operators
  • PHP Arrays
  • PHP Loops
    • PHP If … Else
    • PHP While
    • PHP Foreach
    • PHP For
    • PHP Switch/Case
  • PHP Functions
  • PHP Forms
    • $_GET
    • $_POST
    • $_REQUEST
  • PHP Cookies
  • PHP Sessions


  1. PHP Introduction: http://www.w3schools.com/PHP/php_intro.asp
  2. PHP Syntax: http://www.w3schools.com/PHP/php_syntax.asp
  3. Learn PHP from Scratch: A Training Regimen: http://net.tutsplus.com/tutorials/php/learn-php-from-scratch-a-training-regimen/


Read More

How to Install XAMPP on Ubuntu


If you are a Linux (or Ubuntu) web developer or even a web designer with interest in CMS systems like WordPress, Drupal, Joomla etc., you are for sure in need of a web development environment on your work computer to test websites or themes that you built for any CMS. If you have not fund a solution yet, the good news is that there is one – it is XAMPP.

Read More

How to remove nofollow attribute from your WordPress blog

As you may already know, WordPress the rel=”nofollow” attribute in comments. That makes any comment with a link on it have no significance for Google when they ranks websites. Getting rid of the rel=”nofollow” attribute is one of the tactics that many WordPress bloggers follow to get more people comment on their blogs. And in my view, this is quite fair – comments add content to a certain blog, the blog pays them back with a link that will be counted by Google, will rise their pagerank and make their way up in Google searches. So, let’s begin.

There are two ways through which you can turn off rel=”nofollow” attribute in your blog:

1. Changing WordPress Core

Editing WordPress core might not be a good idea for bloggers who are not very familiar with coding. For others, like me, who can do any code editing, online through FTP or offline, this is something that they do everyday. That would save the time of downloading, installing and making work another plugin. However, keep in mind that you need to redo this action every time you do an upgrade.

There is only one file you need to edit and all you have to do is remove the word nofollow. This word is located at wp-includes/comment-template.php on line 148. It looks like this:

{code type=php}
$return = “$author“;

All you have to do is remove the word nofollow only and save the file.  This is it!


2. Employing a Plugin

If you do not feel comfortable with editing the WordPress core, you can employ a plugin to do that for you. Keep in mind that you will have the plugin too, when new versions are released. Below you will find a list of such plugins. Chose the one that is good for you and install it.

  1. DoFollow 4.0
  2. NoFollow Free
  3. Lucia’s Linky Love
  4. Sem NoFollow
  5. Link Love
  6. Remove Nofollow

Time for publicity: By removing the nofollow attribute you are giving something away for free to your visitors, tell this to your visitors. You will motivate more people to comment for sure. Good luck!

PS: Don’t forget that WPlancer is a DoFollow blog and I love to hear what you think. Thanks!

Read More

WordPress Bug: Tags do not appear under WP_Query

WordPress has been perfect and bug-free for me. However, I discovered one lately. Firstly I came across this bug when I was developing an Gawker-style WordPress theme for a client of mine. I used custom WP_Query loops several times there and I was asked to display tags inside them too, the way Gawker does. This did not happen, of course, that is why I am writing this post. By that time I thought it was my fault that tags did not appear.

A couple of weeks ago, I coded a new theme for my blog. I used several custom loops there too, powered by the famous WP_Query. When I tried again to show the tags inside them, they did not show up. That made assured me that it was a bug. To have more context about this, please have a look at the following WordPress loop:

{code type=php}

<?php $my_query = new WP_Query(‘category_name=featured&showposts=1’);
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate[$post->ID] = $post->ID; ?>

<div class=”featured_post” id=”post-<?php the_ID(); ?>”>

<img src=”<?php echo get_post_meta($post->ID, ‘Featured_Image’, true) ?>” alt=”” id=”featured_img” />

<h3 class=”title”><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a>  </h3>

<div class=”meta”>By <strong><?php the_author();?></strong> &raquo;

<?php comments_popup_link(‘0 comments’, ‘1  comment’, ‘% comments’); ?>

<?php the_tags(); ?>


<?php the_excerpt() ?>


<?php endwhile; ?>


As you can see, the tags code is included in the loop, but nothing appears. This does not work only under the WP_Query powered loops, whereas in a normal loop, it works. I would appreciate very much that everybody contributes to make this bug known to the WordPress team as soon as possible so that they can have it fixed. Thanks very much!

Read More
1 2