Thursday, March 2, 2017

WordPress Interview Questions And Answers

I am going to provide the most frequent queries you can expect to be asked while going for the Wordpress job interview. These questions are asked by many popular companies in the interview round to the candidates applying for the job of CMS developer or WordPress Developer. Many queries in this post are really tricky and can confuse even the professional developers so if you are going for the job interview then I highly recommend you to check these latest WordPress CMS interview questions and answers.



What is WordPress?

Word press is a best Open Source CMS which allows it to be used free of cost.  You can use it on any kind of personal or commercial website without have to pay a single penny for it. It is built on PHP/MySQL (which is again Open Source) and licensed under GPL.

How safe is website on WordPress?

 The word press is safe to operate but still it is suggested to keep updating with the latest version of WordPress to avoid hacking.

Are there any limitations to a WordPress web site?

You can use WordPress for e-commerce sites, membership sites, photo galleries and any other type of site you can think of. The web site is created using the same html code as any other site so there are no limitations there either.

Do you need to have a blog in order to use WordPress for site?

WordPress was originally used as blogging software though it has since become popular for website also.  It is not necessary to have a blog to use wordpress.  Still having blog is commendable as it will help in search engine optimization.

From SEO point of view is wordpress helpful? Will it show the website on Google?

 It is one of the benefit of using wordpress, it has inbuilt SEO search engine. Also, you can have an additional plug-in in wordpress to help with SEO and rank on a popular search engine like Google.

What is the current version of wordpress?

You need to quote the current version of WordPress available in market along with the release date.

What are the types of hooks in WordPress and mention their functions?

There are two types of hooks 1) Action hooks 2) Filter hooks

Hooks allow user to create WordPress theme or plugin with shortcode without changing the original files. Action hooks allow you to insert an additional code from an outside resource, whereas, Filter hooks will only allow you to add a content or text at the end of the post.


What do you mean by custom field in wordpress?

Custom field is a meta-data that allows you to store arbitrary information to the wordpress post. Through custom field extra information can be added to the post.

What are the positive aspects of wordpress?

Few positive aspects of wordpress are

Easy installation and upgrade
In-built SEO engine
Easy theme system
Flexibility
Multilingual- available in more than 70 languages
Own data- no unwanted advert on your website
Flexibility and Easy publishing option

What are the rules that you have to follow for wordpress plugin development?

Create a unique name
Create the plugin’s folder
Create a sub-folder for PHP files,  translations and assets
Create the main plug-in file and fill in header information
Create activation and de-activation functions
Create an uninstall script
Create a readme.txt file
To detect paths to plugin file use proper constants and functions
11) What is the prefix of wordpress tables by default?

By default, wp_ is the prefix for wordpress.

Why does WordPress use MySQL?

MySQL is widely available database server and is extremely fast.  It is an open source and it is available at no cost also it is supported by many low-cost Linux hosts so its easy for anyone to host their website.

Is it possible to rename the WordPress folder?

Yes, it is possible to rename the WordPress folder.  If WordPress is already installed you have to login to the weblog as the administrator and then change the settings

WordPress address (URI)  :

Blog address( URI) :

After making the changes, you can rename the folder or directory with the WordPress file in it.

How many tables are there in WordPress by default?

There are about 11 tables in WordPress by default. Note: With succeeding releases of WordPress this number will change. You need to check phpMyAdmin to determine the number of tables in a vanilla version of latest WordPress installation.

What is WordPress loop?

To display post WordPress use PHP code, this code is known as loop.

How you can disable the WordPress comment?

If you go on dashboard under options-discussion there is a comment “ Allow people to post comment” try unchecking the comment.

What are the steps you can take if your WordPress file is hacked?

Install security plug-ins like WP security
Re-install the latest version of WordPress
Change password and user-ids for all your users
Check your themes and plug-ins are up to date

What are the template tags in WordPress?

In WordPress template tags is a code that instructs WordPress to "do" or "get" something.

Does WordPress have cookies?

Yes, WordPress have cookies and WordPress uses cookies for verification of users while logged in.

Also Read: html5 Interview Questions and Answers for Freshers

In what case you don’t see plugin menu?

You can’t see your plugin menu when the blog is hosted on free wordpress.com as you cannot add plugin there.  Also, if you do not have an account of an administrator level on your WordPress is not possible to see plugin.

At what instance you get locked out of your WordPress admin and see your website as a blank screen?

This would likely happen when you have pasted a code from a website with wrong formats, also when you have pasted a code in a wrong location. It may also happen when your IP is banned

Why you use a static front page in wordpress?

Some WordPress users wants their WordPress installation to be more than a blog site. To give their page a look more like a real website page some users use static front page.

What are the plugins you can use to create contact form in WordPress?

To create a contact form in WordPress you can use plugin like Gravity forms or also you can use a free plugin contact form 7.

Why widget does not show up in the sidebar?

While using widget you have to ensure whether your theme supports the widget and if it does then it must show the sidebar.  If in any case if it happens that you don’t see the sidebar then it might be missing the “function.php” file or file similar to that.  This can also happen if you have forgot to save the changes in the widget or refreshing the older display of the page.

Is there any limitation for using WordPress?

No, there is no limitation for using WordPress.  WordPress can be used for innumerable purpose membership site, e-commerce site, photo-gallery and many more.

How is creating a site on wordpress.org different from wordpress.com?

Most of the things are similar in both except the choices of themes and the usage of plugins.

Why wordpress.com is considered more secure than wordpress.org?

WordPress.com is considered more secure than wordpress.org because they limit the themes and also does not allow installing plugin’s.  However the security is more dependable on how the hosting company is hosting your website(wordpress.org) & also what are the steps they are taking to prevent the security problems.

Does de-activated plugins slow down a WordPress site?

No, de-activated plugins cannot slow down the WordPress site.  Wordpress only loads the active plugins and ignores everything else.

In what case we cannot recommend WordPress to our client?

We cannot recommend WordPress on following situation:

If client is working on non-CMS base project
If site wants complex or innovative e-commerce
In case of enterprise intranet solution
Sites requiring custom scripting solutions.

What are the essential features you look for a theme?

Theme selection differs according to the requirement, but an ideal theme would be something that would not restrict to use the number of pages, plugins or static homepage.

How Custom theme is different than Normal theme?

Custom theme allows for SEO search, but with a SEO plugin available it would not make much difference to normal theme. One benefit using the Custom theme is that it allows to make the changes without going much into the coding part.

How you can create a static page with WordPress?

To create a static page in wordpress, in the page section  you have to upload a php files to the server in the theme folder, and then select that as your template.  This allows you to add any page and look that you wanted for your blog and it will remain static.

Is there any other CMS better WordPress?

WordPress is no doubt a good CMS, but Drupal and Joomla are among the best CMS you can work with.

Which is the best multi-lingual plugin for wordpress?

Keeping all the limitations in mind, WPML would be the best multi-lingual plugin for wordpress .

Can you update your own content on the site?

It depends on the type of the site or project, but yes one can update their own content on the site.

Also Read: jQuery Interview Questions and Answers for Freshers

What are meta-tags?

Meta-tags are keywords and description used to display website or page information.

What should one use for plugin development - custom post types or custom database tables?

There is no specific preference for plugin development; it depends on what type of plugin’s one has to develop. Though few recommend custom post type, as it has few benefits comparison to custom database table.

Can you host WordPress using  Amazon web services such as EC2, RDS, EBS etc?

Yes, you can host using Amazon web services.

Is there any way to write series in WordPress?

You can use organize series plugin to write series in wordpress.

What are the reasons why one should not hack WordPress core file?

The best reason not to hack the core files is that whatever you might be doing has to be reworked as a patch.

Saturday, February 25, 2017

html5 Interview Questions and Answers for Freshers

HTML5 is a markup language used for structuring and presenting content on the World Wide Web. It is the fifth and current version of the HTML standard.
It was published in October 2014 by the World Wide Web Consortium (W3C) to improve the language with support for the latest multimedia, while keeping it both easily readable by humans and consistently understood by computers and devices such as web browsers, parsers, etc. HTML5 is intended to subsume not only HTML 4, but also XHTML 1 and DOM Level 2 HTML.



Here are we study some popular and frequently asked interview questions for HTML5.

What is HTML5?
HTML5 is the next major revision of the HTML standard superseding HTML 4.01, XHTML 1.0, and XHTML 1.1. HTML5 is a standard for structuring and presenting content on the World Wide Web.

New Semantic Elements − These are like <header>, <footer>, and <section>.

Forms 2.0 − Improvements to HTML web forms where new attributes have been introduced for <input> tag.

Persistent Local Storage − To achieve without resorting to third-party plugins.

WebSocket − A a next-generation bidirectional communication technology for web applications.

Server-Sent Events − HTML5 introduces events which flow from web server to the web browsers and they are called Server-Sent Events (SSE).

Canvas − This supports a two-dimensional drawing surface that you can program with JavaScript.

Audio & Video − You can embed audio or video on your web pages without resorting to third-party plugins.

Geolocation − Now visitors can choose to share their physical location with your web application.

Microdata − This lets you create your own vocabularies beyond HTML5 and extend your web pages with custom semantics.

Drag and drop − Drag and drop the items from one location to another location on a the same webpage.

Which browsers support HTML5?
The latest versions of Apple Safari, Google Chrome, Mozilla Firefox, and Opera all support many HTML5 features and Internet Explorer 9.0 will also have support for some HTML5 functionality.

The mobile web browsers that come pre-installed on iPhones, iPads, and Android phones all have excellent support for HTML5.

Is HTML5 backward compatible with old browsers?
Yes! HTML5 is designed, as much as possible, to be backward compatible with existing web browsers. New features build on existing features and allow you to provide fallback content for older browsers.

It is suggested to detect support for individual HTML5 features using a few lines of JavaScript.

Are HTML tags case sensitive?
No!

What is the purpose of 'section' tag in HTML5?
This tag represents a generic document or application section. It can be used together with h1-h6 to indicate the document structure.

is the purpose of 'article' tag in HTML5?
This tag represents an independent piece of content of a document, such as a blog entry or newspaper article.

What is the purpose of 'aside' tag in HTML5?
This tag represents a piece of content that is only slightly related to the rest of the page.

What is the purpose of 'header' tag in HTML5?
This tag represents the header of a section.

What is the purpose of 'footer' tag in HTML5?
This tag represents a footer for a section and can contain information about the author, copyright information, et cetera.
What is the purpose of ‘nav’ tag in HTML5?
This tag represents a section of the document intended for navigation.

What is the purpose of ‘dialog’ tag in HTML5?
This tag can be used to mark up a conversation.

What are custom attributes in HTML5?
A custom data attribute starts with data- and would be named based on your requirement. Following is the simple example−

<div class=”example” data-subject=”physics” data-level=”complex”>
…
</div>
The above will be perfectly valid HTML5 with two custom attributes called data-subject and data-level. You would be able to get the values of these attributes using JavaScript APIs or CSS in similar way as you get for standard attributes.

What is Web Forms 2.0?
Web Forms 2.0 is an extension to the forms features found in HTML4. Form elements and attributes in HTML5 provide a greater degree of semantic mark-up than HTML4 and remove a great deal of the need for tedious scripting and styling that was required in HTML4.

What is the purpose of datetime input control in Web form 2.0?
It represents a date and time (year, month, day, hour, minute, second, fractions of a second) encoded according to ISO 8601 with the time zone set to UTC.

What is the purpose of datetime-local input control in Web form 2.0?
It represents a date and time (year, month, day, hour, minute, second, fractions of a second) encoded according to ISO 8601 with no time zone information.

What is the purpose of date input control in Web form 2.0?
It represents a date (year, month, day) encoded according to ISO 8601.

What is the purpose of month input control in Web form 2.0?
It represents a date consisting of a year and a month encoded according to ISO 8601.

What is the purpose of week input control in Web form 2.0?
It represents a date consisting of a year and a week number encoded according to ISO 8601

What is the purpose of time input control in Web form 2.0?
It represents a time (hour, minute, seconds, fractional seconds) encoded according to ISO 8601.

What is the purpose of email input control in Web form 2.0?
This accepts only email value. This type is used for input fields that should contain an e-mail address. If you try to submit a simple text, it forces to enter only email address in email@example.com format.

What is the purpose of url input control in Web form 2.0?
This accepts only URL value. This type is used for input fields that should contain a URL address. If you try to submit a simple text, it forces to enter only URL address either in http://www.example.com format or in http://example.com format.

What is the purpose of ‘output’ tag in HTML5?
HTML5 introduced a new element <output> which is used to represent the result of different types of output, such as output written by a script.

What is the purpose of ‘placeholder’ attribute in HTML5?
HTML5 introduced a new attribute called placeholder. This attribute on <input> and <textarea> elements provides a hint to the user of what can be entered in the field. The placeholder text must not contain carriage returns or line-feeds.

What is the purpose of ‘autofocus’ attribute in HTML5?
This is a simple one-step pattern, easily programmed in JavaScript at the time of document load, automatically focus one particular form field.

What is the purpose of 'required' attribute in HTML5?
HTML5 introduced a new attribute called required which would insist to have a value in an input control.
Yes! HTML5 allows embeding SVG directly using <svg>…</svg> tag.

Can you use MathML tags directly in HTML5 without any plugin?
Yes! The HTML syntax of HTML5 allows for MathML elements to be used inside a document using <math>…</math> tags.

What are the drawbacks of cookies?
Cookies have following drawbacks−
Cookies are included with every HTTP request, thereby sending data unencrypted over the internet.

Cookies are limited to about 4 KB of data . Not enough to store required data.
What do you mean by session storage in HTML5?
HTML5 introduces the sessionStorage attribute which would be used by the sites to add data to the session storage, and it will be accessible to any page from the same site opened in that window i.e. session and as soon as you close the window, session would be lost.

What do you mean by local storage in HTML5?
HTML5 introduces the localStorage attribute which would be used to access a page’s local storage area without no time limit and this local storage will be available whenever you would use that page.

When a session storage data gets deleted?
The Session Storage Data would be deleted by the browsers immediately after the session gets terminated.

When a local storage data gets deleted?
local storage data has no time limit. To clear a local storage setting you would need to call localStorage.remove(‘key’); where ‘key’ is the key of the value you want to remove. If you want to clear all settings, you need to call localStorage.clear() method.

What is Server Side Events in HTML5?
Along with HTML5, WHATWG Web Applications 1.0 introduces events which flow from web server to the web browsers and they are called Server-Sent Events (SSE). Using SSE you can push DOM events continously from your web server to the visitor’s browser.

The event streaming approach opens a persistent connection to the server, sending data to the client when new information is available, eliminating the need for continuous polling.

Server-sent events standardizes how we stream data from the server to the client.

How to utilize a server-sent event in HTML5?
To use Server-Sent Events in a web application, you would need to add an <eventsource> element to the document.

The src attribute of <eventsource> element should point to an URL which should provide a persistent HTTP connection that sends a data stream containing the events.

The URL would point to a PHP, PERL or any Python script which would take care of sending event data consistently.

What are the steps of server side scripts for SSE?
server side script should send Content-type header specifying the type text/event-stream as follows−

print "Content-Type: text/event-stream\n\n”;
After setting Content-Type, server side script would send an Event − tag followed by event name. Following example would send Server-Time as event name terminated by a new line character.

print "Event: server-time\n”;
Final step is to send event data using Data − tag which would be followed by integer of string value terminated by a new line character as follows−

$time = localtime();
print "Data: $time\n";

What are web sockets?
Web Sockets is a next-generation bidirectional communication technology for web applications which operates over a single socket and is exposed via a JavaScript interface in HTML 5 compliant browsers.

Once you get a Web Socket connection with the web server, you can send data from browser to server by calling a send() method, and receive data from server to browser by an onmessage event handler.

Following is the API which creates a new WebSocket object.

var Socket = new WebSocket(url, [protocal] );
Here first argument, url, specifies the URL to which to connect. The second attribute, protocol is optional, and if present, specifies a sub-protocol that the server must support for the connection to be successful.
What is the purpose of Socket.readyState atribute of WebSocket?
The readonly attribute readyState represents the state of the connection. It can have the following values:

A value of 0 indicates that the connection has not yet been established.

A value of 1 indicates that the connection is established and communication is possible.

A value of 2 indicates that the connection is going through the closing handshake.

A value of 3 indicates that the connection has been closed or could not be opened.

What is the purpose of ‘canvas’ tag in HTML5?
HTML5 element <canvas> gives you an easy and powerful way to draw graphics using JavaScript. It can be used to draw graphs, make photo compositions or do simple (and not so simple) animations.

What is the purpose of ‘audio’ tag in HTML5?
HTML5 supports <audio> tag which is used to embed sound content in an HTML or XHTML document. The current HTML5 draft specification does not specify which audio formats browsers should support in the audio tag. But most commonly used audio formats are ogg, mp3 and wav.

You can use <source> tag to specify media along with media type and many other attributes. An audio element allows multiple source elements and browser will use the first recognized format.

What is the purpose of ‘video’ tag in HTML5?
HTML5 supports <video> tag which is used to embed a video file in an HTML or XHTML document.The current HTML5 draft specification does not specify which video formats browsers should support in the video tag. But most commonly used video formats are−

Ogg − Ogg files with Thedora video codec and Vorbis audio codec.

mpeg4 − MPEG4 files with H.264 video codec and AAC audio codec.

You can use <source> tag to specify media along with media type and many other attributes. An audio element allows multiple source elements and browser will use the first recognized format.
What is Geolocation API in HTML?
HTML5 Geolocation API lets you share your location with your favorite web sites. A Javascript can capture your latitude and longitude and can be sent to backend web server and do fancy location-aware things like finding local businesses or showing your location on a map.

Today most of the browsers and mobile devices support Geolocation API. The geolocation APIs work with a new property of the global navigator object ie. Geolocation object which can be created as follows:

var geolocation = navigator.geolocation;
The geolocation object is a service object that allows widgets to retrieve information about the geographic location of the device.

What is purpose of getCurrentPosition() method of geolocation object of HTML5?
This method retrieves the current geographic location of the user.

What is purpose of watchPosition() method of geolocation object of HTML5?
This method retrieves periodic updates about the current geographic location of the device.

What is purpose of clearPosition() method of geolocation object of HTML5?
This method cancels an ongoing watchPosition call.

What are Web Workers?
Web Workers do all the computationally expensive tasks without interrupting the user interface and typically run on separate threads.

Web Workers allow for long-running scripts that are not interrupted by scripts that respond to clicks or other user interactions, and allows long tasks to be executed without yielding to keep the page responsive.
What is the purpose of datetime-local input control in Web form 2.0?
It represents a date and time (year, month, day, hour, minute, second, fractions of a second) encoded according to ISO 8601 with no time zone information.




Thursday, February 23, 2017

Apache Solr Interview Questions and Answers

Solr is an open source enterprise search platform, written in Java, from the Apache Lucene project. Its major features include full-text search, hit highlighting, faceted search, real-time indexing, dynamic clustering, database integration, NoSQL features and rich document (e.g., Word, PDF) handling. Providing distributed search and index replication, Solr is designed for scalability and fault tolerance.Solr is the second-most popular enterprise search engine after Elasticsearch.


Solr is very popular now a days for web development. Here we are listing most popular and frequently asked Solr interview questions with answers:

What is Apache Solr?
Apache Solr is a standalone full-text search platform to perform searches on multiple websites and index documents using XML and HTTP. Built on a Java Library called Lucence, Solr supports a rich schema specification for a wide range and offers flexibility in dealing with different document fields. It also consists of an extensive search plugin API for developing custom search behavior.

What file contains configuration for data directory?
Solrconfig.xml file contains configuration for data directory.

What file contains definition of the field types and fields of documents?
schema.xml file contains definition of the field types and fields of documents.

What are the features of Apache Solr?
• Allows Scalable, high performance indexing Near real-time indexing
• Standards-based open interfaces like XML, JSON and HTTP
• Flexible and adaptable faceting
• Advanced and Accurate full-text search
• Linearly scalable, auto index replication, auto failover and recovery
• Allows concurrent searching and updating
• Comprehensive HTML administration interfaces
• Provides cross-platform solutions that are index-compatible

What is Apache Lucene?
Supported by Apache Software Foundation, Apache Lucene is a free, open-source, high-performance text search engine library written in Java by Doug Cutting. Lucence facilitates full-featured searching, highlighting, indexing and spellchecking of documents in various formats like MS Office docs, HTML, PDF, text docs and others.

What is request handler?
When a user runs a search in Solr, the search query is processed by a request handler. SolrRequestHandler is a Solr Plugin, which illustrates the logic to be executed for any request.Solrconfig.xml file comprises several handlers (containing a number of instances of the same SolrRequestHandler class having different configurations).

What is the use of field type?
Field type defines how Solr would interpret data in a field and how that field can be queried.

What all information is specified in field type?
A field type includes four types of information:
• Name of field type
• Field attributes
• An implementation class name
• If the field type is Text Field , a description of the field analysis for the field type.

Explain Faceting in Solr.
As the name suggests, Faceting is the arrangement and categorization of all search results based on their index terms. The process of faceting makes the searching task smoother as users can look for the exact results.

Also Read: PHP Interview Questions for Freshers with Answers

What are the advantages and disadvantages of Standard Query Parser?
Also known as Lucence Parser, the Solr standard query parser enables users to specify precise queries through a robust syntax. However, the parser’s syntax is vulnerable to many syntax errors unlike other error-free query parsers like DisMax parser.

Define Dynamic Fields?
Dynamic Fields are a useful feature if users by any chance forget to define one or more fields. They allow excellent flexibility to index fields that have not been explicitly defined in the schema.
analyzing of input text is performed at the time of searching or indexing and at query time. Most Solr applications use Custom Analyzers defined by users. Remember, each Analyzer has only one Tokenizer. You can define an analyzer in the application using the below syntax:

What is the use of tokenizer?
It is used to split a stream of text into a series of tokens, where each token is a subsequence of characters in the text. The token produced are then passed through Token Filters that can add, remove or update the tokens. Later,that field is indexed by the resulting token stream.

What is phonetic filter?
Phonetic filter creates tokens using one of the phonetic encoding algorithms in the org.apache.commons.codec.language package.

What is SolrCloud?
Apache Solr facilitates fault-tolerant, high-scalable searching capabilities that enable users to set up a highly-available cluster of Solr servers. These capabilities are well revered as SolrCloud.

What is copying field?
It is used to describe how to populate fields with data copied from another field.

What is Highlighting?
Highlighting refers to the fragmentation of documents matching the user’s query included in the query response. These fragments are then highlighted and placed in a special section, which is used by clients and users to present the snippets. Solr consists of a number of highlighting utilities having control over different fields. The highlighting utilities can be called by Request Handlers and reused with standard query parsers.

Name different types of highlighters?
There are 3 highlighters in Solr:
• Standard Highlighter: provides precise matches even for advanced queryparsers.
• FastVector Highlighter: Though less advanced than Standard Highlighter, it works better for more languages and supports Unicode breakiterators.
• Postings Highlighter: Much more precise, efficient and compact than the above vector one but inappropriate for a more number of query terms.

What is the use of stats.field?
It is used to generate statistics over the results of arbitrary numeric functions.

What command is used to see how to use the bin/Solr script?
Execute $ bin/Solr –helpto see how to use the bin/Solr script.

Also Read: jQuery Interview Questions and Answers for Freshers

Which syntax is used to stop Solr?
$ bin/solr stop -p 8983 is used to stop Solr.

Which command is used to start Solr in foreground?
$ bin/solr start –f is used to start Solr in foreground.

$ bin/solr status is used to check Solr running status.

Give the syntax to start the server.
$ bin/solr start is used to start the server.

How to shut down Apache Solr?
Solr is shut down from the same terminal where it was launched. Click Ctrl+C to shut it down.

What data is specified by Schema?
Schema declares –
• how to index and search each field
• what kinds of fields are available
• what fields are required
• what field should be used as the unique/primary key

Name the basic Field types in Solr.
• date
• long
• double
• text
• float

How to install Solr?
The three steps of Installation are:
1. Server-related files, e.g. Tomcat or start.jar (Jetty)
2. Solr webapp as a .war
3. Solr Home which comprises the data directory and configuration files

What are the important configuration files of Solr?
Solr supports two important configuration files
1. solrconfig.xml
2. schema.xml

What are the most common elements in solrconfig.xml?
The most common elements in solrconfig.xml are:
1. Search components
2. Cache parameters
3. Data directory location
4. Request handlers





Monday, October 17, 2016

Some Common Mistakes that PHP Developers Make

One of the best things about PHP is that it is  a great language to just 'dive into'. Thanks to its wide-ranging popularity, anyone with the ability to hit "Search" on Google can quickly create a program. However, this also lends to a major criticism of PHP, i.e. it is almost too easy to find and reproduce bad code.

Here are some mistakes that any PHP programmer, regardless of skill level, might make at any given time. Some of the mistakes are very basic, but unfortunately, they can trip up even the best PHP programmer! Other mistakes are hard to spot (even with strict error reporting). However, all  these mistakes have one thing in common: They are  easy to avoid.!


Single quotes, double quotes
It's easy to just use double quotes when concatenating strings because it parses everything neatly without having to deal with escaping characters and using dot values. However, using single quotes has considerable performance gains, as it requires less processing.

Consider this string:
[code]
$boo = 'everyone';
$foo = 'hello $boo';
$bar = "hello $boo";
[/code]


$foo outputs to "hello $boo" and $bar gives us "hello everyone". That's one less step that PHP has to process. It's a small change that can make significant gains in the performance of the code.

NOT Using database caching
If you use a database in your PHP application, it is strongly advised that you at least use some sort of database caching. Memcached has emerged as the most poplar caching system, with mammoth sites like Facebook endorsing the software.


Memcached is free and can provide very significant gains to your software. If your PHP is going into production, it is strongly advised to use the caching system.

Not Using E_ALL Reporting

Error reporting is a very handy feature in PHP, and if you're not already using it, you should really turn it on. Error reporting takes much of the guesswork out of debugging code, and speeds up your overall development time.

While many PHP programmers may use error reporting, many aren't utilizing the full extent of error reporting. E_ALL is a very strict type of error reporting, and using it ensures that even the smallest error is reported. (That's a good thing if you're wanting to write great code.)

When you're done developing your program, be sure to turn off your reporting, as your users probably won't want to see a bunch of error messages on pages that otherwise appear fine. (Even with the E_ALL error reporting on they hopefully won't see any errors anyway, but mistakes do happen.)

Not Escaping Entities
Many times PHP programmers are too trusting with data, especially data generated by user. It's imperative to sanitize data before it goes into any sort of storage, like a database.

Source Rally shows us how to correctly escape entities in things like forms. Instead of using this:

echo $_GET['username'];

You can validate the data by using htmlspecialchars() (or htmlentities()) like so:

echo htmlspecialchars($_GET['username'], ENT_QUOTES);

Using Wrong Comparison Operators
While comparison operators are an extremely basic part PHP programming, mixing these up in your code is certain to bork your program. As the German proverb states, the devil is in the details!


Being familiar with the often-misused operators like =, ==, != , are absolutely critical to PHP programming. Taking the time to really understand the differences will greatly speed up your programming and yield less bugs to debug.

Not using PDO
Don’t get me wrong, mysqli is (quite literally) generations ahead of the ancient mysql extension. It’s kept up to date, secure, reliable and fast. However, it’s mysql specific. Using PDO instead would let you use some wonderfully practical object oriented syntax, and would prepare you for tango with other SQL databases like PostgreSQL, MS SQL, and more. What’s more, PDO will let you use named parameters, a feature so useful, few people can imagine going to anything else after having taken proper advantage of it.
Last but not least, there’s this: you can inject fetched data directly into a new object, which is a delightful timesaver in large projects.

Not rewriting URLs
Another commonly ignored and easy to fix issue. URLs like mypage.com/index.php?p=43&g=24 are just not acceptable in this day and age. Due to it being incredibly difficult to write a good URL rewriting guide that would cover every server and framework out there, almost every framework has a guide on how to set up clean URLs (Laravel, Phalcon, Symfony, Zend) and any that don’t just aren’t worth using – they obviously don’t care about modern practices.

Not optimizing your queries
99% of PHP performance problems will be caused by the database, and a single bad SQL query can play havoc with your web application. MySQL’s EXPLAIN statement, the Query Profiler, and many other tools can help you find that rogue SELECT.

Using * in SELECT queries
Never use * to return all columns in a table–it's lazy. You should only extract the data you need. Even if you require every field, your tables will inevitably change.

Under or over-indexing
As a general rule of thumb, indexes should be applied to any column named in the WHERE clause of a SELECT query.

For example, assume we have a usertable with a numeric ID (the primary key) and an email address. During log on, MySQL must locate the correct ID by searching for an email. With an index, MySQL can use a fast search algorithm to locate the email almost instantly. Without an index, MySQL must check every record in sequence until the address is found.


It is tempting to add indexes to every column, however, they are regenerated during every table INSERT or UPDATE. That can hit performance; only add indexes when necessary.

Forgetting to back up
It may be rare, but databases fail. Hard disks can stop. Servers can explode. Web hosts can go bankrupt. Losing your MySQL data is catastrophic, so ensure you have automated backups or replication in place.


Tuesday, June 7, 2016

10 Best Online Resources to Learn jQuery

jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
Looking at the popularity of JQuery it is a must to learn for all the developers and designers. So, here we bring you a list of top 10 free online resources where you can master your JQuery skills.


Learn.jQuery is the best place to start learning as it focuses on basics, deals with common problems faced by developer and makes you familiar with the standard practices of JQuery. 


It covers topic such as JQuery introduction, events, Ajax calls, use of plugins, code organization etc.


jQuery API Documentation is another place to start learning as it focuses on jQuery API, deals with common problems faced by developer and makes you familiar with the standard API of JQuery.


 It covers topic such as JQuery introduction, events, Ajax calls, use of plugins, code organization etc.


Tutorialspoint has been in these business from a long time and explain things in the simplest way possible. The JQuery course is very structured and can be understood even by a beginner.


 It starts with the basics and covers topic like attributes, CSS, DOM, AJAX etc. and then move towards advanced topics like Interactions, Widgets, Theming, Plugin and Utilities.


Snoopcode provide you a Step-by-step introduction to the jQuery. Learn the building blocks of jQuery and make the web more interactive with custom animations


At the end of the jQuery tutorial, you can find more than 100 examples. With online editor, you can edit and test each example yourself.

Codeademy is place to start learning jQuery as it focuses on basics, introduction of jQuery. It covers topic such as JQuery functions, dynamic HTML, jQuery events, effects and jQuery projects.



Stackoverflow, the best website to learn jQuery is your own website, seriously. Give yourself a tough project and just google for solutions to any obstacles, there is no better way to learn than pure experience. You will write horrible code, and as fast as a couple days later you'll be able to recognize the horrible mistakes you made a week earlier, but never stop and never feel confident.


The first year at least will consist almost entirely of this incremental learning process, even when you feel you've got it all down. stackoverflow.com is the best website to learn by practice and fix your own practical issue.


7) w3 Schools
w3schools is doing a remarkable job in providing tutorials on various technologies. You just name the technology and you will find a tutorial related to that on w3schools. The tutorials on JQuery covers every topic and has an online editor as well where you can perform things practically.


The tutorial starts with an introduction of JQuery and then digs deep into the technology as we progress further.

8) jqfundamentals
jQuery Fundamentals is designed to get you comfortable working through common problems you'll be called upon to solve using jQuery. To get the most out of this site, you'll want to read the content and try the various interactive examples.

Each chapter will cover a concept and give you a chance to try example code related to the concept.

9) jquery-tutorial 
jquery-tutorial helps you learn jQuery online so that you can leverage your skills in creating animation and building interactive websites. Tutorials covers all jQuery basics and step by step explanation to learn jQuery.


10) Learning jQuery

Learning jQuery is designed to get you Tips, techniques, and tutorials for the jQuery JavaScript library.

This website provides tutorials for Bignner, intermediate and for Advace.

So these are the 10 the best free website to learn jQuery in easily and better manner. Hope you all will love those resources.


Saturday, May 21, 2016

PHP Tips and Tricks to Improve Your Programming Skills

Guys if you love to PHP programming. Listed below are some excellent techniques that PHP developers should learn and use every time they program. They can improve their PHP programming skills to follow these tricks.


Avoid the use of printf function
Unlike print and echo, printf() is a function with associated function execution overhead. More over printf() is designed to support various formatting schemes. To handle formatting printf() needs to scan the specified string for special formatting code that are to be replaced with variables.
<?php
echo 'FinalResult:', $result;  
// is better than
printf("FinalResult.%s", $result );
?>

echo is faster than print
PHP is giving some sting functions to printing output into browser and we are often using print() and echo() function.
Print() function behavior like the other function in common and having return value integer 1. Thus, print() can used as part of expression which more complex. Meanwhile, echo() is able to accept more than one parameters all at once, and does not having return value.
<?php
print() 'string 1';
echo 'string 1';
// using some parameters
echo 'string 1', "string 2", '...';
?>

echo() function string will execution more faster than print(). This differentiate caused by will return status (integer) which expose what process has done or not.

Loops and Counting
Here are some ways to make your loops and counting a bit more efficient.
Use pre-calculations and set the maximum value for your for-loops before and not in the loop. This means you are not calling the count() function on every loop.

$max = count($array);
for ($i = 0; $i < $max; $i++)
//is faster than
for ($i = 0; $i < count($array); $i++)
When checking the length of strings:
Use isset where possible in replace of strlen. (cite)
if (!isset($foo{5})) { echo "Foo is too short"; }
//is faster than
if (strlen($foo) < 5) { echo "Foo is too short"; }


Single Quotes vs Double Quotes
You may or may not think about this point in your PHP use but it is kind of a big deal. Using the right or wrong quotes can not only cause errors that might be hard to find but there can be a slight performance boost and can make your code much easier to read.
    <?php
         echo 'hello world in techbowl';
    ?>
    <?php
         echo "hello world in techbowl";
    ?>
These will produce the exact same end result but do you know which one is technically better? The single quote. The single quote just puts exactly what is inside of it without processing while the double quote actually evaluates and processes. Let’s take an example.
    <?php
   
          $example = 'hello world in techbowl';
   
          echo '$example'; // outcome will be $example
   
          echo "$example"; // outcome will be hello world in techbowl
    ?>
As you can see here the double quotes take the time to process what is inside so technically there will be a little more overhead.
Obviously on a small scale this means nothing but if you have a loop that iterates 1000 or more times you might start to see the benefits of single quotes in a performance sense.

When incrementing:
Use pre-incrementing where possible as it is 10% faster.
++$i;
//is faster than
$i++;
And
Incrementing an undefined local variable is 9-10 times slower than a pre-initialized one.

Accessing arrays
For Example:  $result['post_id'] is 7 times faster than $result[post_id]

Avoid functions inside loops
Try to use functions outside loops. Otherwise the function may get called each time and obviously it will affect performance.
<?php

    /*  loop with a count() inside the control block will be
        executed on EVERY loop iteration.
    */
    $count = count( $array );  
    for( $i = 0; $i < $count; $i++ )  
    {  
        // do something here
    }  
     
    // is better than          
    for( $i = 0; $i < count( $array ); $i++ )  
    {  
        // do something here
    }
?>
It's even faster if you eliminate the call to count() AND the explicit use of the counter by using a foreach loop in place of the for loop.
<?php
    foreach ($array as $i) {
        // do something  
    }
?>


Use absolute paths in includes and requires
It means less time is spent on resolving the OS paths.
include('/var/www/html/your_app/test.php');
//is faster than
include('test.php');
require() and include() are identical in every way except require halts if the file is missing. Performance wise there is very little difference.

true is faster than TRUE
This is because when looking for constants PHP does a hash lookup for name as is & since names are always stored lower cased, by using them you avoid 2 hash lookups. Furthermore, by using 1 and 0 instead of TRUE and FALSE, can be considerably faster.

Use isset() instead of strlen() function
<?php
$str = "45e23";
if (!isset($str{5})) {
    echo 'String must be at least 5 characters<br />';
}
if (strlen($str) < 5){
    echo 'String must be at least 5 characters;
}
?>
isset() needs little more time than strlen() because isset() is a language construct.
When you treat strings as arrays, each character in the string is an element in the array. By determining whether a particular element exists, you can determine whether the string is at least that many characters long. (Note that the first character is element 0, so $str[5] is the sixth character in $str)

Use ternary operators instead of if, else
Ternary operators can be very helpful and clean up the code, but don’t over complicate them otherwise your code might become inundated with large amounts of complex ridiculousness.
<?php
$name = (!empty($_GET['name'])? $_GET['name'] .'techbowlarticle');
?>

one-liner to convert XML into associative array.
<?php
$arr = json_decode(json_encode(simplexml_load_string($xml, null, LIBXML_NOCDATA)), true);
?>


Maintain debugging environment in your application

During development we echo database queries , dump variables which are creating problems , and then once the problem is solved , we comment them or erase them. But its a good idea to let everything stay and help in the long run

On your development machine you can do this :

[code]
define('ENVIRONMENT' , 'development');

if(! $db->query( $query )
{
    if(ENVIRONMENT == 'development')
    {
        echo "$query failed";
    }
    else
    {
        echo "Database error. Please contact administrator";
    }  
}
[/code]

And on the server you can do this :\
[code]
define('ENVIRONMENT' , 'production');

if(! $db->query( $query )
{
    if(ENVIRONMENT == 'development')
    {
        echo "$query failed";
    }
    else
    {
        echo "Database error. Please contact administrator";
    }  

}
[/code]

Omit the closing php tag if it is the last thing in a script
Let's have a look on below code
<?php

echo "Hello";

//Now dont close this tag

This will save you lots of problem. Lets take an example :

A class file super_class.php
<?php
class super_class
{
    function super_function()
    {
        //super code
    }
}
?>
//super extra character after the closing tag
Now index.php

require_once('super_class.php');

//echo an image or pdf , or set the cookies or session data
And you will get Headers already send error. Why ? because the "super extra character" has been echoed , and all headers went along with that. Now you start debugging. You may have to waste many hours to find the super extra space.

Hence make it a habit to omit the closing tag :

<?php
class super_class
{
    function super_function()
    {
        //super code
    }
}

//No closing tag
That's better.


So there were few tricks and tips to improve the PHP programming skills, hope you will follow these and love these.


Wednesday, May 11, 2016

Interesting and Strange Facts about PHP, Every Developer should know

Are you getting started with PHP ? Then you gotta know these facts about php. It will help to generate interest in yourself and encourage others to learn php.


Many of these facts are reason for PHP being so popular.
  • PHP originally stood for Personal Home Page.
  • PHP which is now officially known as 'Hypertext Preprocessor' was released in the year 1995.
  • Initially written as a set of Common Gateway Interface (CGI) in 'C' (1994).
  • PHP was originally designed to replace a set of Perl scripts to maintain his Personal Home Pages (also known as PHP).
  • PHP was originally created by Rasmus Lerdorf in 1995. He wrote the original Common Gateway Interface (CGI) binaries.
  • Zeev Suraski and Andi Gutmans, two developers at the Technion IIT, rewrote the parser in 1997 and formed the base of PHP 3.
  • PHP 3 was official launched in June 1998.
  • Suraski and Gutmans rewrote the PHP 3's core, producing the Zend Engine in 1999. They also founded Zend Technologies in Ramat Gan, Israel.
  • On May 22, 2000, PHP 4, powered by the Zend Engine 1.0, was released.
  • The main implementation of PHP is now produced by The PHP Group and serves as the de facto standard for PHP as there is no formal specification.
  • On July 13, 2004, PHP 5 was released, powered by the new Zend Engine II. PHP 5 introduced full featured object-oriented programming support. It was there in PHP 3 and PHP 4 but only the basic features.
  • PHP is free software released under the PHP License, which is incompatible with the GNU General Public License (GPL) due to restrictions on the use of the term PHP.
  • PHP was originally designed to create dynamic and more interactive web pages. It is the most widely-used, open-source and general-purpose scripting language.
  • It is possible to use PHP in almost every operating system. PHP can be used in all major operating systems including Linux, Microsoft Windows, Mac OS X, and RISC OS.
  • PHP uses procedural programming or object oriented programming and also a mixture of them.
  • PHP is installed on over 20 million websites and 1 million web servers. (PHP: 244M sites, 2.1M IP addresses) http://php.net/usage.php
  • 75% of Web 2.0 sites are built in PHP. PHP is used by 81.7% of all the websites whose server-side programming language we know.
  • There are about 5 million PHP developers worldwide.
  • The latest release of PHP till now is 7.0.6. It was released on April 29, 2016. During 2014 and 2015, a new major PHP version was developed, which was numbered PHP 7. The numbering of this version involved some debate. While the PHP 6 Unicode experiment had never been released, several articles and book titles referenced the PHP 6 name, which might have caused confusion if a new release were to reuse the name. After a vote, the name PHP 7 was chosen
  • Some of the biggest online brands, such as Facebook, ProProfs, Digg, Friendster, Flickr, Technorati, and Yahoo! are powered by PHP
Popular sites using PHP
  • Facebook.com
  • Wikipedia.org
  • Qq.com
  • Taobao.com
  • Wordpress.com
  • Sina.com.cn
  • Vk.com
  • Mail.ru
  • Weibo.com
Strange PHP Facts about PHP

Floating Point Imprecision

Most of you probably know that floating-point numbers cannot really represent all real numbers. Besides, some operations between two well represented numbers can lead to surprising situations. This is because the finite precision with which computers represent numbers and so it affects not just PHP but all the programming languages. Inaccuracies in floating point problems have been given programmers headaches from the beginning of the discipline.
Let's look at this very small snippet:

echo (int) ((0.1 + 0.7) * 10);

What do you think will be the result? If you guessed 8, you'd be wrong I'm sorry, This code will actually print 7. 

Now let's see why this happens. The first operation executed is:

0.1 + 0.7 // result is 0.79999999999

The result of the arithmetic expression is stored internally as 0.7999999, not 0.8 due to the precision issue, and this is where the problem starts.

The second operation executed is:

0.79999999 * 10 = 7.999999999

This operation works well but preserves the error.

The third and last operation executed is:

(int) 7.9999999 // result is 7

The expression makes use of an explicit cast. When a value is convert to int, PHP truncates the decimal portion of the number which makes the result 7.

There are two interesting things to note here:
  • If you cast the number to float instead of int, or if you don’t cast at all, you'll get 8 as result as you expected.
  • Although the CPU doesn’t know, and we actually we got this error due to its imprecisions, it's working accordingly to the mathematics paradox that asserts 0.999… is equal to 1.

How PHP "Increments" Strings

During our everyday work we write instructions that perform incrementing/decrementing operations like these:

$a = 5;
$b = 6;
$a++;
++$b;

Everyone easily understands what’s going on with those statements. But given the following statements, guess what will be the output:

$a = 1;
$b = 3;
echo $a++ + $b;
echo $a + ++$b;
echo ++$a + $b++;

Did you write down your answers? Good. Let's check all.

4
6
7
Not too difficult, right? Now let’s raise the bar a little. Have you ever tried to increment strings? Try to guess what the output will be for the following:

$a = 'fact_2';
echo ++$a;

$a = '2nd_fact';
echo ++$a;

$a = 'a_fact';
echo ++$a;

$a = 'a_fact?';
echo ++$a;

It’s not so easy this time, is it. Let’s uncover the answers.

fact_3
2nd_facu
a_facu
a_fact?
Surprised? Using an increment operator on a string that ends with a number has the effect of increasing the letter (the one following it in the alphabet, e.g. t -> u). Regardless if the string starts with digits or not, the last character is changed. But there is no effect if the string ends with a non-alphanumeric character.

This is well documented by the official documentation about the incrementing/decrementing operators but most of you may not have read it because you probably thought nothing special was there. I must admit I thought the same until a short time ago.

The Mystery of Value Appearance

You’re a real array master in PHP, admit it. Don’t be shy. You already know everything about how to create, manage, and delete arrays. Nonetheless, the next example might surprise you at first sight.

Often you work with arrays and need to search if a given value is in an array. PHP has a function for this, in_array(). Let’s see it in action:

$array = array(
  'isReady' => false,
  'isPHP' => true,
  'isStrange' => true
);
var_dump(in_array('techbowl.in', $array));

What will be the output? Place your bets and let’s check it.

true
Isn’t this a little bit strange? We have an associative array where its values are all boolean and if we search for a string, we got true. Has this value magically appeared? Let’s see another example.

$array = array(
  'count' => 1,
  'references' => 0,
  'ghosts' => 1
);
var_dump(in_array('pawan', $array));

And what we get is…

true
Once again the in_array() function returns true. How is this possible?

You’re experiencing one of both best and worst, loved and hated PHP features. PHP isn’t strongly typed and this is where the error starts. In fact, all the following values, if compared in PHP, are considered the same unless you use the identity operator:

0
false
""
"0"
NULL
array()
By default, the in_array() function uses the loose comparison, a non-empty ("") and non-zero-filled ("0") string is equal to true and to all non-zero numbers (like 1). Hence, in the first example we got true because 'techbowl.in' == true, while in the second we have 'aurelio' == 0.

To solve the problem you've to use the third and optional parameter of in_array() that allows you to compare the values strictly. So, if we write:

$array = array(
  'count' => 1,
  'references' => 0,
  'ghosts' => 1
);
var_dump(in_array('pawan', $array, true));

we'll finally get false as we expect!



Tuesday, May 10, 2016

Top Zend Framework Interview Questions with Answer

Zend is most popular PHP Framework by function and features that makes Zend unique from other frameworks, thousand of components and library and more. it's  a MVC based architecture that makes web application development makes popular and efficient.
If you go to any interview for Zend developer position, there are lot of questions and answers which can help you to crack the interview.



What is a framework?
In software development, a framework is a defined support structure in which another software project can be organized and developed.

Why should we use framework?
Framework is a structured system where we get following things
Rapid application development(RAD).
Source codes become more manageable.
Easy to extend features.

Where we set configuration in zend framework?
We set the config in application.ini which is located in application/configs/application.ini.

What is Front Controller?
It used Front Controller pattern. zend also use singleton pattern.

  • routeStartup: This function is called before Zend_Controller_Front calls on the router to evaluate the request.
  • routeShutdown: This function is called after the router finishes routing the request.
  • dispatchLoopStartup: This is called before Zend_Controller_Front enters its dispatch loop.
  • preDispatch: called before an action is dispatched by the dispatcher.
  • postDispatch: is called after an action is dispatched by the dispatcher.

What is full form of CLA in Zend Framework?
Contributor License Agreement

Should I sign an individual CLA or a corporate CLA?
If you are contributing code as an individual- and not as part of your job at a company- you should sign the individual CLA. If you are contributing code as part of your responsibilities as an employee at a company, you should submit a corporate CLA with the names of all co-workers that you foresee contributing to the project.

How to include js from controller and view in Zend?

From within a view file: 
$this->headScript()->appendFile('filename.js');

From within a controller:

$this->view->headScript()->appendFile('filename.js');

And then somewhere in your layout you need to echo out your headScript object:

headScript();?>


What are Naming Convention for PHP File?

  • There should not any PHP closing tag (?>)in controller & Model file.
  • Indentation should consist of 4 spaces. Tabs are not allowed.
  • The target line length is 80 characters, The maximum length of any line of PHP code is 120 characters.
  • Line termination follows the Unix text file convention. Lines must end with a single linefeed (LF) character. Linefeed characters are represented as ordinal 10, or hexadecimal 0x0A
What are Naming Convention for Classes, Interfaces, FileNames, Functions, Methods, Variables and constants?
http://framework.zend.com/manual/1.11/en/coding-standard.naming-conventions.html 


What are coding style of Zend Framework?
http://framework.zend.com/manual/1.12/en/coding-standard.coding-style.html

How to use update statemnet in Zend Framework?
[code]
  class Application_Model_Users extends Zend_Db_Table_Abstract {
    protected $_name = 'users';
    protected $_primary = 'id';

    function updateData($updateData = array()) {
        //please update dynamic data
        $this->update(array('name' => 'arun', 'type' => 'user'), array('id=?' => 10));
    }
}
[/code]

How we can do multiple column ordering in Zend Framework?
[code]
  class Application_Model_Users extends Zend_Db_Table_Abstract {
    protected $_name = 'users';
    protected $_primary = 'id';

    function users() {
        $select = $this->select()
        ->setIntegrityCheck(false)
        ->from(array('u' => 'users'), array('name as t_name'))->order('first_name asc')->order('last_name des');
         return $this->fetchAll($select);
    }

}
[/code]

How to get all GET data?
[code]
$this->getRequest()->getParams();
[/code]

How to redirect to another page from controller?
[code]
$this->_redirect('/users/login');
[/code]

How to get variable's value from get?
[code]
$id= $this->getRequest()->getParam('id');
[/code]

Create Model file in zend framework?
[code]
class Application_Model_Users extends Zend_Db_Table_Abstract {
    protected $_name = "users";
    protected $_primary = "id";    
}
[/code]

How to create object of Model?
[code]
$userObj = new Application_Model_Users();
[/code]

Which Class extend the Zend Controller?

Zend_Controller_Action
For Example
[code]
class AjaxController extends Zend_Controller_Action {
}
[/code]

Which Class extend the zend Model?
Zend_Db_Table_Abstract
For Example
[code]
class Application_Model_Users extends Zend_Db_Table_Abstract { }
[/code]

Is Zend Framework a component library or a framework?

ZF is both. Zend Framework provides all the components required for most web applications in a single distribution. But Zend Framework components are also loosely coupled, making it easy to use just a few components in a web application- even alongside other frameworks! Using this use-at-will architecture, we are implementing features commonly found in more monolithic frameworks. In fact, we are currently working on a tooling component for the 1.8 release that will make it simpler to build applications using ZF components, yet will not sacrifice the use-at-will nature of existing ZF components.

What is autoloader?
Autoloader is function that load all the object on start up.

What is use of Zend front controller?
Routing and dispatching is managed in the front controller. It collects all the request from the server and handles it.

What is the use of Bootstrap?
Apart from index if we want to do any extra configuration regarding database and other things that is done within bootstrap.

How you can set Module name, Controller name, and Action name in Zend framework?
$request->setModuleName('front');
 $request->setControllerName('address');
 $request->setActionName('addresslist');

Configuration in Zend Framework, application.ini file?
Configuration can be done in application.ini file in Zend framework. This file in the path application/configs/application.ini.

Checking whether form posted or not in Zend framework?
$request = $this->getRequest();
$getData = $request->getParams();
$postData = $request->getPost();
$isPost = $request->isPost();

Fetch last inserted id, fetch all record,find and fetch a single record.
$this->_db->lastInsertId();
$this->_db->fetchAll($sql);
$this->_db->find($id);
$this->_db->fetchRow($sql);

Difference between Zend_Registry and Zend_Session?
Zend_Registry is used to store objects/values for the current request. In short, anything that you commit to Registry in index.php can be accessed from other controllers/actions (because EVERY request is first routed to the index.php bootstrapper via the .htaccess file). Config parameters and db parameters are generally prepped for global use using the Zend_Registry object.

Zend_Session actually uses PHP sessions. Data stored using Zend_Session can be accessed in different/all pages. So, if you want to create a variable named ‘UserRole’ in the /auth/login script and want it to be accessible in /auth/redirect, you would use Zend_Session.

When do we need to disable layout?
At the time of calling AJAX to fetch we need to disable layout.
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);

How to call two different views from same action?
Example1:
Public function indexAction() {
If(condition)
$this->render('yourview.phtml');
Else
Index.phtml;
Example2:
Public function indexAction() {
}
Now in your index.phtml you can have this statement to call other view

$this->action('action name','controller name','module name',array('parameter name'=>'parameter value'));

Can we call a model in view?
Yes, you can call a model in view. Simple create the object and call the method.
$modelObj = new Application_Model_User();

Can we rename the application folder ?
yes, we can

Can we move the index.php file outside the public folder?
yes, we can

How to include css from controller and view in zend?
// From within a view file: 
$this->headLink()->appendStylesheet('filename.css'); 
// From within a controller: 
$this->view->headLink()->appendStylesheet('filename.css'); 
And then somewhere in your layout you need to echo out your headLink object: 
headLink();?> 

How do you protect your site from sql injection in zend when using select query?
We have to quote the strings,
$this->getAdapter ()->quote (  );
$select->where ( "  = ",  );
OR (If you are using the question mark after equal to sign)
$select->where ( " = ? ",  );

What is zend helpers?
It can be divided in two parts,
a) Action Helper: the helper is created for controller
b) View Helper: the helper is created for view files (.phtml).

What is the difference between Zend_Auth and Zend_Acl?
Zend_Auth is used for authenticating users with a variety of authentication methods, including LDAP, OpenID, and HTTP. Authentication is the process of verifying that the provided credentials are valid for the system. By authenticating to your system, your users can prove that they are who they say they are. For more information on Zend Framework's authentication implementation, see the Zend_Auth documentation.
Zend_Acl is an implementation of Access Control List (ACL) authorization. Generally speaking, ACLs are lists of roles that are authorized to perform a particular operation on specific resources in your system. Zend_Acl can support advanced rule definitions with features such as multiple inheritance for roles and assertions for conditional rules. For more information on Zend_Acl, see the Zend_Acl documentation.
Zend_Auth and Zend_Acl can be used together to build very sophisticated security systems: first the user confirms their identity with Zend_Auth, then this identity is used to assign one or more Zend_Acl roles to the user for authorization to use or modify resources in the system