This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Tuesday, 14 January 2014

How to debug code in Drupal?

Simple using print_r or var_export , you can debug code within Drupal.
<?php
$node = node_load(123);
print_r($node);
?>
Drupal devel module provides dsm and dpm functions to debug code within drupal.
<?php
$node = node_load(123);
dpm($node);?>
drupal latest version provides debug inbuilt function to print errors, notices and warnings as well.This could be in the page or in the logs depending on how php is configured.
For example,
<?php
$node = node_load(123);
debug($node);
?>
The full options for debug function are:
debug($data, $label, $print_r);
The $data is pretty self explanatory. It can be anything you could pass through print_r or var_export. The $label allows for a custom label to be added. This is ideal when you are sending the information to a log and you want a key to search the logs for. The 3rd argument is whether to use print_r or var_export. The default is var_export. If you are interested between the two I’d suggest reading the manual pages.

How do you handle upgrades?

Steps to Upgrade drupal minor version.
  • backing up the site,
  • putting it into maintenance mode
  • downloading the new version of the module
  • uncompressing it
  • running update.php
  • testing the site
  • taking the site out of maintenance mode
Steps to Upgrade Drupal major version.
  • Backup your existing site and database.
  • Log in as user ID 1
  • Put your site in maintenance mode
  • Change all themes to Garland
  • Disable non-core modules
  • Remove default settings file
  • Remove all old core files and directories
  • Remove uninstalled modules
  • Download Drupal 7
  • Re-apply modifications to core files
  • Make your settings.php file writeable
  • Run the update script
  • Backup your database
  • Upgrade fields
  • Update contrib modules and themes
  • Check the Status Report
  • Make sure settings.php is secure
  • Check Drupal Core Modules
  • Remove your site from Maintenance Mode

What is Database abstraction layer in Drupal ?

Allow the use of different database servers using the same code base.
Drupal provides  an abstraction layer  with the ability to support multiple database servers easily. The intent of this layer is to preserve the syntax and power of SQL as much as possible, while letting Drupal control the pieces of queries that need to be written differently for different servers and provide basic security checks.
Most Drupal database queries are performed by a call to db_query() or db_query_range(). Module authors should also consider using pager_query() for queries that return results that need to be presented on multiple pages, and tablesort_sql() for generating appropriate queries for sortable tables.

How database system of Drupal works ?

In Drupal, each type of information has its own database table. For instance, the basic information about the nodes of your site are stored in the Node table, Comments and Users also have their own database tables, and roles, permissions, and other settings are also stored in database tables.

Friday, 15 November 2013

How php language execute?

php is a interpretend language

An interpreted language is a programming language that executes instructions directly, without previously compiling a program into machine-language instructions. The interpreter executes the program directly, translating each statement into machine code on the fly as required. Compiled language programs, on the other hand, must explicitly be entirely translated ("compiled") into a sequence of machine language instructions before they can be executed.

What is the difference between strstr() and stristr()?

strstr -- Find first occurrence of a string and get the string from that character

strstr() example

<?php
$mail = 'pass@examplem.com';
$domain = strstr($mail, '@');
echo $domain; // prints @examplem.com
?>

stristr -- Case-insensitive strstr()

stristr() example

<?php
$email = 'USER@EXAMPLE.com';
echo stristr($email, 'e');
// outputs ER@EXAMPLE.

What are the differences between split, implode and explode?



split() and explode() are aliases for one-another. implode() and join() are
aliases for each other. i believe the name was originally explode(), but
split() was chosen later to suit perl programmers.

Twitter Delicious Facebook Digg Stumbleupon Favorites More