Subscribe:

Featured Posts

Monday, May 21, 2012

PHP Interview Questions and Answers


1.   What does a special set of tags <?= and ?> do in PHP?
The output is displayed directly to the browser.
2.   What’s the difference between include and require?
It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
3.   I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?
PHP Interpreter treats numbers beginning with 0 as octal. Look at the similar PHP interview questions for more numeric problems.
4.   Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example?
In this example it wouldn’t matter, since the variable is all by itself, but if you were to print something like "{$a},000,000 mln dollars", then you definitely need to use the braces.
5.   How do you define a constant?
Via define() directive, like define ("MYCONSTANT", 100);
6.   How do you pass a variable by value?
Just like in C++, put an ampersand in front of it, like $a = &$b
7.   Will comparison of string "10" and integer 11 work in PHP?
Yes, internally PHP will cast everything to the integer type, so numbers 10 and 11 will be compared.
8.   When are you supposed to use endif to end the conditional statement?
When the original if was followed by : and then the code block without braces.
9.   Explain the ternary conditional operator in PHP?
Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.
10.                How do I find out the number of parameters passed into function?
func_num_args() function returns the number of parameters passed in.

Sunday, May 13, 2012

PHP OOPS Interview Questions & Answers


1) Explain what is object oriented programming language?
Object oriented programming language allows concepts such as modularity, encapsulation, polymorphism and inheritance.  Objects are said to be the most important part of object oriented language. Concept revolves around making simulation programs around an object. Organize a program around its data (object)& set well define interface to that data. i.e. objects and a set of well defined interfaces to that data. OOP is the common abbreviation for Object-Oriented Programming.  OOps have many properties such as DataHiding,Inheritence,Data Absraction,Data Encapsulation and many more.
2) Name some languages which have object oriented language and characteristics?
Some of the languages which have object oriented languages present in them are ABAP, ECMA Script, C++, Perl, LISP, C#, Tcl, VB, Ruby, Python, PHP, etc. Popularity of these languages has increased considerably as they can solve complex problems with ease.
3) Explain about UML?
UML or unified modeling language is regarded to implement complete specifications and features of object oriented language. Abstract design can be implemented in object oriented programming languages. It lacks implementation of polymorphism on message arguments which is a OOPs feature.
4) Explain the meaning of object in object oriented programming?
Languages which are called as object oriented almost implement everything in them as objects such as punctuations, characters, prototypes, classes, modules, blocks, etc. They were designed to facilitate and implement object oriented methods.
5) Explain about message passing in object oriented programming?
Message passing is a method by which an object sends data to another object or requests other object to invoke method. This is also known as interfacing. It acts like a messenger from one object to other object to convey specific instructions.
6) State about Java and its relation to Object oriented programming?
Java is widely used and its share is increasing considerably which is partly due to its close resemblance to object oriented languages such as C++. Code written in Java can be transported to many different platforms without changing it. It implements virtual machine.
7) What are the problems faced by the developer using object oriented programming language?
These are some of the problems faced by the developer using object oriented language they are: -
a) Object oriented uses design patterns which can be referred to as anything in general.
b) Repeatable solution to a problem can cause concern and disagreements and it is one of the major problems in software design.
8 ) State some of the advantages of object oriented programming?
Some of the advantages of object oriented programming are as follows: -
a) A clear modular structure can be obtained which can be used as a prototype and it will not reveal the mechanism behind the design. It does have a clear interface.
b) Ease of maintenance and modification to the existing objects can be done with ease.
c) A good framework is provided which facilitates in creating rich GUI applications.
9 ) Explain about inheritance in OOPS?
Objects in one class can acquire properties of the objects in other classes by way of inheritance. Reusability which is a major factor is provided in object oriented programming which adds features to a class without modifying it. New class can be obtained from a class which is already present.

10) Explain about the relationship between object oriented programming and databases?
Object oriented programming and relational database programming are almost similar in software engineering. RDBMS will not store objects directly and that’s where object oriented programming comes into play. Object relational mapping is one such solution.
11) Explain about a class in OOP?
In Object oriented programming usage of class often occurs. A class defines the characteristics of an object and its behaviors. This defines the nature and functioning of a specified object to which it is assigned. Code for a class should be encapsulated.
12) Explain the usage of encapsulation?
Encapsulation specifies the different classes which can use the members of an object. The main goal of encapsulation is to provide an interface to clients which decrease the dependency on those features and parts which are likely to change in future. This facilitates easy changes to the code and features.
13) Explain about abstraction?
Abstraction can also be achieved through composition. It solves a complex problem by defining only those classes which are relevant to the problem and not involving the whole complex code into play.
14) Explain what a method is?
A method will affect only a particular object to which it is specified. Methods are verbs meaning they define actions which a particular object will perform. It also defines various other characteristics of a particular object.
15) Name the different Creational patterns in OO design?
There are three patterns of design out of which Creational patterns play an important role the various patterns described underneath this are: -
a) Factory pattern
b) Single ton pattern
c) Prototype pattern
d) Abstract factory pattern
e) Builder pattern
16) Explain about realistic modeling?
As we live in a world of objects, it logically follows that the object oriented approach models the real world accurately. The object oriented approach allows you to identify entities as objects having attributes and behavior.
17) Explain about the analysis phase?
The anlaysis or the object oriented analysis phase considers the system as a solution to a problem in its environment or domain. Developer concentrates on obtaining as much information as possible about the problem. Critical requirements needs to be identified.

Friday, April 27, 2012

ESSENTIAL PLUGINS FOR WORDPRESS BEGINNERS – WORDPRESS TIP


So if you are a beginner in WordPress or you want a quick cheat sheet on what plugins to install here are some of my recommendations:
  1. Google XML Sitemaps:This plugin is a must. It will automatically generate a sitemap of your WordPress blog. As a beginner in WordPress this is very helpful because you won’t have to deal with any code or any xml generation to get the Sitemap file. If you don’t know what the sitemap.xml file is used for I will explain to you. The sitemap.xml file will allow your blog to reveal a Site Map of all your internal pages so that search engines such as google can get a deep analysis of every single page in your site and index you appropriately. This is an essential plugin when beginning a new WordPress blog.
  2. iRobots SEOThe robots.txt file gives instructions to the search engines on what to index and what to skip (for example you don’t want your wp-admin zone to be indexed). This essential plugin will be great for a WordPress beginner or new blog since it will have default setups that will take care of the most important variables in a properly written robots.txt file.
  3. Google AnalyticatorThis is a very simple but efficient plugin to install on a new wordpress site. It will allow you to connect your Google Analytics website as well as to setup easily some options for it. Have you ever not wanted to track your own visits to your WordPress blog? This essential plugin for wordpress will allow you to block yourself easily from the settings page of the plugin once installed.
  4. Yoast WordPress SEOThis is one of the best plugins I have found lately for Search engine optimization. Definitely a must install in a new WordPress blog or website. This plugin will provide you the essential options to adjust how your website is exposed to search engines. It will also provide you a very intuitive way of adding your meta description, title tag and keywords to any post while at the same time giving you advise on how to do it appropriately. I used other plugins before and discovered this one recently and as a geek I can tell you its a fundamental plugin to install.
  5. Akismet
    This comes with WordPress but many people just ignore it. This will give you a protective barrier against spam comments on your website. To activate it you just go to Akismet and register. After you do this they will provide you an API key that you will be able to insert in the Akismet plugin settings
  6. Permalink EditorPermalinks are the URL of your blog posts or pages. WordPress by default lets you setup a standard or dynamic structure. However to get further customization options, this plugin is beautiful. It will enable a “Customize” button beside your URL when editing blog posts. Have you ever wanted to change the category in which the URL is appearing or just change the text? This plugin will allow you to do that easily.
  7. Comprehensive Google Map Plugin (Extra but not essential)This is not for every blog, but just in case you want to use a map in your site to show your location, business venues or any other thing its a personally favorite one. I install this in almost every blog I setup in WordPress since the plugin will be eventually used at some point.
That’s it. I was talking about essential plugins not the top 5, 10 or 15 WordPress plugins. These plugins will allow any beginner to have its blog setup with proper SEO, sitemap, robot file and other options to make the most of its content.
If you are a setting up your new site, I would also suggest you read these posts as well:

WordPress Optimization Tips and Tricks for Better Performance and Speed


Is your WordPress blog performing at it’s best? How quickly does the page load? Is it sluggish? Your website’s performance is one of the key factors in ensuring that the visitors are having a good experience with your site. So I personally think it is worthwhile to spend some time tuning/optimizing the site for performance. In this article I have listed various tips and tricks on how to speed up a WordPress Site.
Before diving into the optimization tips and tricks I recommend measuring the current performance of the site so you have some benchmarking figures to compare against after you make the changes and see how it has affected the performance.
wordpress-optimization-tips-post-icon

How to Measure the Performance of a Site

1. I use the Page Speed tool from Google to measure performance and try to achieve a score of 85+ out of 100. Page speed has a browser addon to measure the performance of a site. Page Speed analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages.
2. You can also use YSlow Firefox addon to measure the page load time of a site. YSlow is a Firefox add-on integrated with the Firebug web development tool. So to use YSlow you will have to get the Firebug addon and then install the YSlow addon.
website-optimazation
The site in question takes about 23 secons to load which is not a very good page loading time. Some optimization could help!
3. The number of database queries a webpage makes to load the page have an effect on the page load time. You can use the following piece of code in the footer of your theme to find out how many database queries a page is making:
<?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds.
Make sure the webpage is not making any unnecessary database queries.
4. You can use the website speed tester to find out how fast your site loads.
speed_test
Website Speed Tester
5. You can also use the stopwatch on numion.com to test how long it takes to load a webpage.

Basic WordPress Site Optimization Tips and Tricks

  • Upgrade to the latest wordpress release (you should be doing this for security reasons anyway)
  • Use W3 Total Cache WordPress plugin (Forget WP Super Cache). W3 Total Cache is just awesome… even I use it :)
  • Minimize simple unnecessary PHP queries. For example, instead of using <?php get_bloginfo(‘wpurl’); ?> just replace it with your wordpress installation URL so the browser can simply read it instead of making a query.
  • Load javascripts in the footer (The golden rule – CSS on top, javascript on bottom)
  • Kill some plugins that are unnecesary or doesn’t add much value to your site (Disable or delete these plugins)
  • Optimize and Repair your Database from myPhpAdmin. You can use the Optimize DB plugin that does this for you.
  • Check your theme Code (Use valid HTML code)
  • Get a Good hosting

Intermediate to Advanced Optimization Tips

  • Keep your page sizes less than 100kb. Do not use too many unnecessary images and video on a page. Always compress the images appropriately.
  • Combine css files into one big css file (One 50kb file loads a lot faster than five 10kb files)
  • Combine javascripts into one big file.
  • Reduce the number of dynamic PHP and http calls (Use subdomains to share the load)
  • Use external scripts. Instead of placing tons of code in your header.php file, use external scripts. This allows the browser to cache the script so it won’t have to read it for every other page.
  • Add far future expires header to images, CSS and javascript files (How to Add far future expires header).
  • Don’t use ETags unless you are taking advantage of it (How to configure ETags).

Thursday, April 19, 2012

First Intel-powered smartphone to be launched in India

Intel has confirmed details of the first smartphone to be powered by one of its processors.



The XOLO X900, made by the Indian manufacturer Lava, will go on sale on 23 April priced at about 22,000 rupees (£265).

Lava has teamed up with Indian retail chain Croma to distribute the device across the country.

The move follows Intel's previous failed attempt to break into the smartphone market.

A tie-up with manufacturer LG in 2010 fell flat, with no models going into production.

Meanwhile, chips designed by British-based ARM and the American firm Qualcomm now dominate the market.

Details of Intel-powered smartphones made by Motorola Mobility and Lenovo are expected soon.

Hyper threading
The chip maker announced the partnerships at the Consumer Electronics Show in Barcelona in January.

Intel's tie-up with Motorola Mobility is seen as most significant as the company is in the process of being purchased by Google.

The Atom-based chip promises more efficient battery consumption, as well as Intel's own "hyper threading technology" allowing for enhanced multi-tasking.

The XOLO X900 - which features an 8-megapixel camera - will run initially on Android Gingerbread, Google's smartphone operating system.

This will later be upgraded, Intel said, to the next incarnation of Android, Ice Cream Sandwich.

Lava has emerged as one of India's fastest-growing companies since being founded two-and-a-half years ago.

"After our success in feature phones, with over 10 million happy customers in under three years, XOLO will be a differentiated player in the fast-growing smartphone segment," Lava's co-founder and director Vishal Sehgal said in a statement.

Thursday, April 12, 2012

Huntington's disease 'lowers' cancer risk

People with Huntington's disease, a debilitating brain condition, appear have a "protection" from cancer, according to a study in Sweden.



Nearly 40 years of medical records showed patients with Huntington's had half the normal expected risk of developing tumours.

Researchers, writing in The Lancet Oncology, said the reason was unclear.

Cancer Research UK said the findings presented another avenue to explore in tackling cancer.

Academics at Lund University analysed Swedish hospital data from 1969 to 2008. They found 1,510 patients with Huntington's disease.

During the study period, 91 of those patients subsequently developed cancer. The authors said that was 53% lower than the levels expected for the general population.

Huntington's is one of a group of illnesses called "polyglutamine diseases". Data from other polyglutamine diseases also showed lower levels of cancer.

The authors said: "We found that the incidence of cancer was significantly lower among patients with polyglutamine diseases than in the general population.

"The mechanisms behind the protective effects against cancer are unclear and further research is warranted."

Dr Jianguang Ji, from the Center for Primary Health Care Research at Lund University, told the BBC: "Clarification of the mechanism underlying the link between polyglutamine diseases and cancer in the future could lead to the development of new treatment options for cancer."

Eleanor Barrie, senior science information officer at Cancer Research UK, said: "These are interesting results. It's not clear how the genetic changes that cause Huntington's and other similar diseases could protect against cancer, and research in the lab will help to find out more.

"Scientists at Cancer Research UK and around the world are probing the genetic faults that contribute to cancer in their quest to beat the disease, and this is another potential avenue to explore."

Wednesday, April 11, 2012

Indonesia says only small tsunami waves hit Sumatra after quakes


JAKARTA (Reuters) - Small tsunami waves of around one meter hit the western coast of Indonesia's Sumatra island on Wednesday after a series of major earthquakes, though the country's disaster agency said it was still assessing whether there were any deaths or damage.
The agency expects the worst impact to have been on Simeulue island off Sumatra and forecasts further small aftershocks in the country's westernmost region, but it has lifted its tsunami alert for an area which was devastated by a tsunami in 2004.