Thursday, June 6, 2013

PHP_Trainer_Online_Tutor

bhupendra
PHP & MySQL Course Curriculum
HTML
Introduction to HTML
HTML Documents
Structural Elements Of HTML Documents
Formatting HTML Documents
Managing Images In HTML
Tables In HTML Documents
Hypertext And Link In HTML Documents
Special Effects In HTML Documents
Multimedia
Managing Forms
Introduction to PHP
The Origin of PHP
PHP is better than Its alternatives
Interfaces to External systems
How PHP works with the Web Server
Hardware and Software requirements
What a PHP script looks like
Saving data for later
Receiving user input
Repeating code
Basic PHP Development
How PHP scripts work
Basic PHP syntax
PHP data types
Displaying type information
Testing for a specific data type
Changing type with Set type
Operators
Variable manipulation
Dynamic variables
String in PHP
Control Structures
The if statement
Using the else clause with if statement
The switch statement
Using the ? operator
The while statement
The do while statement
The for statement
Breaking out of loops
Nesting loops
Summary
Functions
What a function
Defining a function
Returning value from function
User-defined functions
Dynamic function calls
Variable scope
Accessing variable with the global statement
Function calls with the static statement
Setting default values for arguments
Passing arguments to a function by value
Passing arguments to a function by reference
Testing for function existence
Arrays
Single-Dimensional Arrays
Multidimensional Arrays
Casting Arrays
Associative arrays
Accessing arrays
Getting the size of an array
Looping through an array
Looping through an associative array
Examining arrays
Joining arrays
Sorting arrays
Sorting an associative arrays
Disk Access, I/O, Math And Mail
HTTP connections
Writing to the browser
Getting input from forms
Output buffering
Session handling
Regular expression
Common math
Random numbers
File upload
File download
Environment variables
E-mail in PHP
Cookies
The anatomy of a cookie
Setting a cookie with PHP
Deleting a cookie
Creating session cookie
Working with the query string
Creating query string
Session
What is session
Starting a session
Working with session variables
Destroying session
Passing session IDs
Encoding and decoding session variables
Working With The File System
Creating and deleting a file
Reading and writing text files
Working with directories in PHP
Checking for existence of file
Determining file size
Opening a file for writing, reading, or appending
Writing Data to the file
Reading characters
Working With Forms
Forms
Super global variables
The server array
A script to acquire user input
Importing user input
Accessing user input
Combine HTML and PHP code
Using hidden fields
Redirecting the user
File upload and scripts
Working With Regular Expressions
The basic regular expressions
PCRE
Matching patterns
Finding matches
Replace patterns
Modifiers
Breakup Strings
Classes And Objects
Objects oriented programming
Define a class
An Object
Creating an object
Object properties
Object methods
Object constructors and destructors
Class constants
Class inheritance
Abstract classes and methods
Object serialization
Checking for class and method existence
Exceptions
Iterators
Summary
Introduction To Database
Introduction to SQL
Connecting to the MYSQL
Selecting a database
Finding out about errors
Adding data to a table
Acquiring the value
Finding the number of rows
Inserting data
Entering and updating data
Executing multiple queries
jQuery
Introduction to jQuery
Syntax
Selectors
Events
Effects
Callback
HTML
CSS
Reference
Selectors
Events
AJAX with jQuery
Joomla
Introduction to Joomla
Installation of Joomla
Template Management
Menu Management
Structure of Modules & Components
ZEND
MVC
Infrastructure
Internationalization
Authentication and Access
Performance
Forms
Security
Diagnosis and Maintainability
Filtering and Validation
search
Database
Mail
Coding Standards
Web Services

Tuesday, June 4, 2013

Zend Interview Questions and Answers

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 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:
<?=$this->headScript();?>


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:
<?=$this->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 ( <variable name> );
$select->where ( ” <field name> = “, <variable name> );
OR (If you are using the question mark after equal to sign)
$select->where ( ” <field name> = ? “, <variable name> );

What is zend framework?
Answer: It is opensource framework created by zend.com (PHP company). It is object oriented and follow the MVC. Zend Framework is focused on building more secure, reliable and fast development.

How to add extra HTML (i.e link) in Zend_Form?
Answer: use Desciption decorator with (escape =false in second parameter).

How can I detect if an optional file has been uploaded?
Answer:  Zend_File_Transfer_Adapter_Http's receive()  return true.

What is Zend registry?
Answer: It is container for object and values  in applications, when you set an object in zend_registry you can access in whole site.

What is Zend_Form?
Answer: It is mainly used to display the form. but along with this we use for filter, validation and formating our form. It have following elements
Element filter
Element validation
Element ordering.
Decorator
Grouping
Sub form
Rendering form elments in single call or one by one for elements.

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 do you know about zend layout.
Answer: It work as a site template and have following features.
                Automatic selection and rendering layout
                Provide separate scope for calling element i.e parital, render, partialLoop

What is Inflection?
Answer: It is class in zend used to modify the string like convert to lowercase, change to url by removing special chars and convert underscore to hyphen.

What is Front Controller?
Answer:  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 Zend_filter?
Zend_filter is used to filter the data as remove the tags, trailing the spaces, remove all except digits.

Difference between Zend_Registry and Zend_Session




The use of these objects was confusing to me at first.. The basic difference between these objects is the ‘scope’ in which they are valid: 

a) Zend_Registry : request scope
b) Zend_Session : session scope

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.

Monday, April 29, 2013

Configure wamp for windows 7

Configure wamp for windows 7

1) ;short_open_tag = Off

REPLACE TO THIS---------------------

short_open_tag = On

2);error_reporting(E_ALL ^ E_DEPRECATED);

 REPLACE TO THIS---------------------------

error_reporting = E_ALL & ~E_NOTICE  & ~E_WARNING & ~E_DEPRECATED



3)rewrite_module




-------------------------------------------------------------------------------
Must be checked in php.ini file

Than Restart Your Wamp Server................

Wednesday, April 3, 2013

What is InnoDB and ACID in DBMS.

bhupendra
bhupendra
ACID
*Atomicity states that database modifications must follow an “all or nothing” rule. Each transaction is said to be “atomic.” If one part of the transaction fails, the entire transaction fails. It is critical that the database management system maintain the atomic nature of transactions in spite of any DBMS, operating system or hardware failure.
* Consistency states that only valid data will be written to the database. If, for some reason, a transaction is executed that violates the database’s consistency rules, the entire transaction will be rolled back and the database will be restored to a state consistent with those rules. On the other hand, if a transaction successfully executes, it will take the database from one state that is consistent with the rules to another state that is also consistent with the rules.
* Isolation requires that multiple transactions occurring at the same time not impact each other’s execution. For example, if Joe issues a transaction against a database at the same time that Mary issues a different transaction, both transactions should operate on the database in an isolated manner. The database should either perform Joe’s entire transaction before executing Mary’s or vice-versa. This prevents Joe’s transaction from reading intermediate data produced as a side effect of part of Mary’s transaction that will not eventually be committed to the database. Note that the isolation property does not ensure which transaction will execute first, merely that they will not interfere with each other.
* Durability ensures that any transaction committed to the database will not be lost. Durability is ensured through the use of database backups and transaction logs that facilitate the restoration of committed transactions in spite of any subsequent software or hardware failures.
infinititsolutions


=============================InnoDB=================================
InnoDB is a transaction-safe (ACID compliant) storage engine for MySQL that has commit, rollback, and crash-recovery capabilities to protect user data. InnoDB row-level locking (without escalation to coarser granularity locks) and Oracle-style consistent nonlocking reads increase multi-user concurrency and performance. InnoDB stores user data in clustered indexes to reduce I/O for common queries based on primary keys. To maintain data integrity, InnoDB also supports FOREIGN KEY referential-integrity constraints. You can freely mix InnoDB tables with tables from other MySQL storage engines, even within the same statement.

Saturday, March 2, 2013

IEC College of Engineering and technology,Batch[2006-2009]bhupendra pratap singh 2009 MCA

bhupendra-pratap-singhIEC College of Engineering and Technology (IECCET), Greater Noida was established in 1999. The institute was approved by AICTE, affiliated to Mahamaya Technical University and Gautam Budh Technical University. The quality of institute is to uncompromising commitment to impart quality technical education by providing an environment of high   academic ambience to mould young minds of future engineers, technocrats and managers to meet the challenges of future with vision, competence and excellence.

The mission of the institute is to create an ambience for quality education, training and research in the fields of science, technology and management, thus contributing towards building of knowledge, industrial development and economic growth of the nation.

 The vision of the institute is to be a seat of world class education from where technocrats and managers would emerge empowered to face the challenges of ever changing society with courage, conviction and compassion.

Facilities at IEC College of Engineering and Technology -

  • Library
  • Classrooms
  • Hostels
  • Internet
  • Auditoriums
  • Computer
  • Sports

History

IEC-CET was established in 1999, for imparting engineering education and for promoting technological research to generate suitable technical manpower.
The institute is affiliated to Mahamaya Technical University and recognised by AICTE.[1]
The IEC-CET, started in 1999, constituted the Faculty of Engineering and Technology. Initially, it offered MCA degree, and a Bachelors of Technology in five branches, namely Computer Science, Electrical Engineering, Electronics and Communication, Mechanical Engineering and Information Technology. Within a few years, two more degree program i.e. MBA and MTech(Power System) were introduced.

Programs

The Institute offers a Bachelors of Technology in the following fields:
  1. Computer Science
  2. Information Technology
  3. Civil Engineering
  4. Mechanical Engineering
  5. Electronics & Communication Engineering
  6. Electrical Engineering
  7. Electronics & Instrumentation
The institute also offers:
  1. MCA
  2. Master of Business Administration
  3. Master of Electrical Power Systems

Infrastructure

The IEC campus is spread over 218 acres (880,000 m2). There are separate blocks for B.Tech, MBA and MCA, PGDM, B.Pharma, and BHMCT programmes.
The colleges and its academic facilities are organized over 160.5 acres (650,000 m2), and the remaining 57.5 acres (233,000 m2) have been kept for residential facilities, a shopping arcade and other commercial ventures that benefit students and staff residing on the campus.

Location

The college is situated in Knowledge Park - I, Gr

Regular Expression Writing with PHP

Writing Regular Expression with PHP

Regular Expression, commonly known as RegEx is considered to be one of the most complex concepts. However, this is not really true. Unless you have worked with regular expressions before, when you look at a regular expression containing a sequence of special characters like /, $, ^, \, ?, *, etc., in combination with alphanumeric characters, you might think it a mess. RegEx is a kind of language and if you have learnt its symbols and understood their meaning, you would find it as the most useful tool in hand to solve many complex problems related to text searches.
Just consider how you would make a search for files on your computer. You most likely use the ? and * characters to help find the files you're looking for. The ? character matches a single character in a file name, while the * matches zero or more characters. A pattern such as 'file?.txt' would find the following files:
file1.txt
filer.txt
files.txt

Using the * character instead of the ? character expands the number of files found. 'file*.txt' matches all of the following:
file1.txt
file2.txt
file12.txt
filer.txt
filedce.txt
While this method of searching for files can certainly be useful, it is also very limited. The limited ability of the ? and * wildcard characters give you an idea of what regular expressions can do, but regular expressions are much more powerful and flexible.
Let Us Start on RegEx
A regular expression is a pattern of text that consists of ordinary characters (for example, letters a through z) and special characters, known as metacharacters. The pattern describes one or more strings to match when searching a body of text. The regular expression serves as a template for matching a character pattern to the string being searched.
The following table contains the list of some metacharacters and their behavior in the context of regular expressions:
Character Description
\ Marks the next character as either a special character, a literal, a backreference, or an octal escape. For example, 'n' matches the character "n". '\n' matches a newline character. The sequence '\\' matches "\" and "\(" matches "(".
^ Matches the position at the beginning of the input string.
$ Matches the position at the end of the input string.
* Matches the preceding subexpression zero or more times.
+ Matches the preceding subexpression one or more times.
? Matches the preceding subexpression zero or one time.
{n} Matches exactly n times, where n is a nonnegative integer.
{n,} Matches at least n times, n is a nonnegative integer.
{n,m} Matches at least n and at most m times, where m and n are nonnegative integers and n <= m.
? When this character immediately follows any of the other quantifiers (*, +, ?, {n}, {n,}, {n,m}), the matching pattern is non-greedy. A non-greedy pattern matches as little of the searched string as possible, whereas the default greedy pattern matches as much of the searched string as possible.
. Matches any single character except "\n".
x|y Matches either x or y.
[xyz] A character set. Matches any one of the enclosed characters.
[^xyz] A negative character set. Matches any character not enclosed.
[a-z] A range of characters. Matches any character in the specified range.
[^a-z] A negative range characters. Matches any character not in the specified range.
\b Matches a word boundary, that is, the position between a word and a space.
\B Matches a nonword boundary. 'er\B' matches the 'er' in "verb" but not the 'er' in "never".
\d Matches a digit character.
\D Matches a nondigit character.
\f Matches a form-feed character.
\n Matches a newline character.
\r Matches a carriage return character.
\s Matches any whitespace character including space, tab, form-feed, etc.
\S Matches any non-whitespace character.
\t Matches a tab character.
\v Matches a vertical tab character.
\w Matches any word character including underscore.
\W Matches any nonword character.
\un Matches n, where n is a Unicode character expressed as four hexadecimal digits. For example, \u00A9 matches the copyright symbol (©).

RegEx functions in PHP
PHP has functions to work on complex string manipulation using RegEx.  The following are the RegEx functions provided in PHP.

Function Description
ereg This function matches the text pattern in a string using a RegEx pattern.
eregi This function is similar to ereg(), but ignore the case sensitivity.
ereg_replace This function matches the text pattern in a string using a RegEx Pattern and replaces it with the given text.
eregi_replace This is similar to ereg_replace(), but ignores the case sensitivity.
split This function split string into array using RegEx.
Spliti This is similar to Split(), but ignores the case sensitivity.
sql_regcase This function create a RegEx from the given string to make a case insensitive match.

Finding US Zip Code
Now let us see a simple example to match a US 5 digit zip code from a string
<?
$zip_pattern = "[0-9]{5}";
$str = "Mission Viejo, CA 92692";
ereg($zip_pattern,$str,$regs);
echo $regs[0];
?>
This script would output as follows
92692
 
Note the change in the RegEx pattern in examples. preg_match() is considered as  faster alternative for ereg().
RegEx for US Phone Numbers
Now let us try to create a RegEx pattern to match a US telephone number.  US telephone numbers are 10 digit numbers usually written with three parts like xxx xxx xxxx.  These three parts are normally used with – hyphen, () braces, and blank spaces. The most common patterns can be seen as follows:
XXX XXX XXXX
(XXX) XXX XXXX
XXX-XXX-XXXX
(XXX) XXX-XXXX
In some cases, US ISD code would be added in the first, like +1 XXX XXX XXXX.
Let us create a Perl-Compatible RegEx pattern to match the above patterns. First we would need to match the single digit ISD code (let us not restrict it to 1). But this may or may not available in the phone numbers, hence we would write it as follows:
$Phone_Pattern = “/(\d)?/”;
Here \d is equivalent to 0-9 and the succeeding ‘?’ indicates that the digit may appear one time or doesn’t appear at all.
Now what would appear next in the sequence? The possibilities are a blank space or a hyphen. So we would add the pattern “(\s|-)?” with the above RegEx. This pattern indicates that either a blank space or a hyphen may or may not appear. So our RegEx becomes:
$Phone_Pattern = “/(\d)?(\s|-)?/”;
The next sequence would be either XXX or (XXX). To match this sequence, we need to first match the braces with the pattern “(\()?”. As we use braces to enclose the patterns in RegEx, braces are metacharacters and to match these metacharacters explicitly, we need to use the escape character “\” preceding the metacharacters. Hence we use “\(“ in our RegEx pattern.  Now we need to match the three digits and a closing braces. So this can be written as “(\d){3}(\))?”. Now our RegEx is added with these patterns,
$Phone_Pattern = “/(\d)?(\s|-)?(\()?(\d){3}(\))?/”;
After the first part XXX, there should be either a blank space or a hyphen. So we add “(\s|-){1}” to the phone pattern.
$Phone_Pattern = “/(\d)?(\s|-)?(\()?(\d){3}(\))?(\s|-){1}/”;
Further construction of RegEx would be much more simpler, as we need to match either XXX-XXXX or XXX XXXX. This could be written as “(\d){3}(\s|-){1}(\d){4}”. Adding this part of pattern to our RegEx,
$Phone_Pattern = “/(\d)?(\s|-)?(\()?(\d){3}(\))?(\s|-){1}(\d){3}(\s|-){1}(\d){4}/”;
Yippee!!! We have created a RegEx to match US phone numbers.

Now we need to use this RegEx to perform some task, so that we can understand the significance of RegEx better. Now let us try to script a code to fetch the phone numbers from Google contact us page. So first we need to fetch the html content from Google’s contact us page.
$str = implode("",file("http://www.google.com/intl/en/contact/index.html"));
 
Then we need to search for the phone number pattern with the help of our “Just Created” RegEx. If we use the preg_match(), we can fetch only one match. So to get more than one match we would use preg_match_all().
preg_match_all($Phone_Pattern,$str,$phone);
Now putting all these pieces into a single script,
<?
$str = implode("",file("http://www.google.com/intl/en/contact/index.html"));
$Phone_Pattern = "/(\d)?(\s|-)?(\()?(\d){3}(\))?(\s|-){1}(\d){3}(\s|-){1}(\d){4}/";
preg_match_all($Phone_Pattern,$str,$phone);
for($i=0;$i<count($phone[0]);$i++)
{
echo $phone[0][$i]."<br>";
}
?>
This script will display the following output,
(650) 253-0000
(650) 253-0001


Wrap Up
Hope you had a good session with RegEx and now you would have some understanding on tackling problems related to text pattern findings using RegEx.  To become a specialist in RegEx, you need to continuously practice it and need to identify complex problems and give a try to solve them. Happy Practicing With RegEx.