Archive for the ‘PHP’ Category

4
Nov

Advantages of PHP – Why Choose PHP

PHP is an extremely popular scripting language. It was originally created in 1995 and designed for the web. It is free of charge and can be used on almost every operating system. There are over 20 million websites and over 1 million web servers running PHP and those numbers are growing every day.

The reason why PHP is so popular and it is continuously growing is because it offers many advantages. These are:

Fast – PHP was created to develop dynamic Web Pages so it is fast on websites. The PHP code is embedded in HTML and the time it takes to process and load the browser with HTML and create a full web page is very quick.

Free – PHP is released under the PHP License. This license is compatible with the GNU General Public License or GPL. Thus making PHP software. This means that anybody can download it and use it 100% for free. Frameworks of WordPress Development & Drupal Development is based on PHP.

Easy - The syntax of PHP is very easy to use and learn. PHP is usually mixed in with HTML and can be easily included in HTML files.

Great Support – Because of its popularity, support for PHP is abundant. There are mailing lists and forums you can join and search for answers. If you’re an organization there are many fantastic developers you can hire to help you out. This is one of the benefits of open source software for businesses; you get the software for free but only pay for support and save yourself a lot of money. Most of Web Design Companies prefer to use PHP.

8
Jul

Display view inside a view

Drupal 6 replaces the views_build_view by views_embed_view, which make sense at least by the name of function.

$viewName = 'MYVIEWNAME';
print views_embed_view($viewName);

The views_embed_view has 2 default arguments. The second argument allows you to enter the display_id of the view (example: default, page, block, etc). Any additional argument you specify will be passed to the views argument handler. For instance, if you wanted to embed the block view and pass it a list of nodeIDs as an argument.

$viewName = 'MYVIEWNAME';
$display_id = 'block';
$myNodes = array(1, 2, 3);
print views_embed_view($viewName, $display_id, $myNodes);
6
Mar

Automatically provide TinyURL for your links

Ever wonder how some sites provide tiny web addresses for your links. Its easy as like eating ice cream.

Create a global public function

function getTinyUrl($url) {
$tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
return $tinyurl;
}

Usage example

$url = 'http://www.google.com/search?hl=en&q=pace+solutions&btnG=Search';
$turl = getTinyUrl(get_permalink($url));
echo 'TinyURL for link is: <a href="'.$turl.'">'.$turl.'</a>';

Output:
TinyURL for link is: http://tinyurl.com/atqflt