Tuesday, August 18, 2009

running php by command line

php 4.3.0 have CLI(command line interface) On by default. Today I am going to say about how to run php by command line in windows.

First of all you need to go to the php folder in your xampp by cmd. If you use svn, then you will have an error saying "Unable to load dynamic library 'E:/xampp/php/ext/php_svn.dll'- the specified module could not be found".

To solve this problem, you need to copy to following files from Apache/bin/ to php/ :

libdb43.dll
intl3_svn.dll
libapr.dll
libapriconv.dll
libaprutil.dll

These will solve the above problem.

Now to execute a php file write the command: php address_of_the_file_to_run(for example E:/xampp/htdocs/tab.php)

you can pass arguments in the command line.And one the server side, you can fetch the argument by the $argv variable, the first element is always the filename that is executing.




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Monday, August 17, 2009

I have become a ZCE

I passed the Zend php 5 certification exam on 09, Aug, 2009. I am really very happy. I like to share my experience with you all. I can't tell about the questions as I was asked by Zend not to disclose any of the questions. But I can share my experience ofcourse. I have given the mock exam of zend. The real exam is much harder than the mock ones. One need to know the php manual must for zend php 5 certifications. You also need to have some knowledge about the some php technique by web searching. This will help you lot, because you can learn many things by searching the web. One also need to study the comments made on the php manual. There are many helpful information regarding many complex techniques in php. Keep seeing this blog, i will keep posting many helpfull topics in this blog in the future.




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Wednesday, August 5, 2009

Database designing with data modeling tool

Database designing is one of the first phase in developing a software.For database designing there are various tools that we can use.The DBDesigner Fork is a very helpful tool for database designing.

You can download DBDesigner Fork from http://sourceforge.net/projects/dbdesigner-fork/.Then click on the DBDesigner.exe under the bin folder.

Let's start on how to design a table first.Click on the table button on the left column.Then click on the worksplace.A table will be created.You can add field names there by double clicking on it.Drag the field name that you want to make as primary key on the primary key box.

There are one-to-one,one-to-many,many-to-many relationship.To create one of the relationship,first click on one of them that you want to apply. Then click on the two tables you want to connect.

You can build sql commands by DBDesigner Fork.Change the design view to sql view by clicking the first button on left menu.On the sql view,click on a table and drag the table below, you will see the drag menu which will help you to build sql commands.




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Tuesday, August 4, 2009

ZEND TEST: UPLOADING FILES

Question : When uploading a file using HTTP, which variable can be used to locate the file on PHP's local filesystem?

Answer :

1. None of the above
2. $_FILES['fieldname']['tmp_name']
3. $_FILES['fieldname']
4. $_FILES['fieldname'][0]['filename']
5. $_FILES['fieldname']['filename']




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

switch control structure in php

Question : The following could be better represented as what?



if($a == 10) {

} elseif ($a == 20) {

} elseif ($a == 30) {

}



Answer:

1. A switch statement without break statements
2. A foreach statement
3. A while statement
4. A switch statement
5. Multiple if statements




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

store information in Http cookie

Question : When is it acceptable to store sensitive information in an HTTP cookie?

Answer:

1. Only under extremely controlled situations
2. When the cookie is sent over a secure HTTP request
3. When it is encrypted
4. It is always acceptable
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

pdo exceptions.

Question: When connecting to a database using PDO, what must be done to ensure that database credentials are not compromised if the connection were to fail?

Answer:

1. wrap the PDO DSN in a try/catch block to catch any connection exception
2. Use constants in the PDO DSN
3. Place the login credentials in the php.ini file
4. Disable E_STRICT and E_NOTICE error reporting levels
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

patterns in zend mock test

Question:

Consider the following series of classes and interfaces
_author;
}
public function getTitle() {
return $this->_title;
}
}
class MyClass2 {
private $_instance;
public function __construct(MyClass $a) {
$this->_instance = $a;
}
public function getTitleAndAuthor() {
$retval = array(
'title' => $this->_instance->getTitle(),
'author' => $this->_instance->getAuthor()
);
return $retval;
}
}
class MyClass3 {
public function doSomething(MyInterface $instance) {
$value = $instance->getTitleAndAuthor();
}
}
?>
MyClass2 is an example of the ________ design pattern.

Answer:

Factory method pattern. As this pattern uses an interface and the subclasses implements that pattern independent of each other.
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

design patterns in php 5

Adaptor pattern helps a class to use some interfaces which are not usable by that class without the adapter class.

Singleton pattern has a private and static constructor.so that there will only one instance of a class.

Abstract factory pattern has some abstract class that are override by other classes.

Decorator pattern adds additional features to an object dynamically.

Observer pattern maintains a one-to-main dependency.so,when one object changes other object updated accordingly.
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

how to read a csv file in php 5

php provides fgetcsv(resource handle[,int length[,string delimiter[,string enclosure[,string escape]]]]) functions. the length is the number of character that will be read in one line, delimiter will be the end character in a line, enclosure will wrap a field, escape string will esacape double quotes.

it will return an array containing datas of the csv file.
following a source code to parse a csv file.

$row = 1;
$filename="keywords.csv";
if(pathinfo($filename,PATHINFO_EXTENSION)=="csv")
{
$handle = fopen($filename, "r");
echo "table cellpadding='3' cellspacing='3'";
while (($data = fgetcsv($handle)) !== FALSE) {
$num = count($data);
$row++;
echo "tr";
for ($c=0; $c < $num; $c++) {
echo "td".$data[$c]."/td";
}
echo "/tr";
}
echo "/table";
fclose($handle);
}
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Monday, August 3, 2009

disable these directives.

Question: Which of the following php.ini directives should be disabled to improve the outward security of your application?

Answer: (chose 4)

1. safe_mode
2. magic_quotes_gpc
3. register_globals
4. display_errors
5. allow_url_fopen
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

function structure in php

Question : What is the output of the following code?




Answer:

1. Error: Unexpected T_VARIABLE
there must be curly braces surrounding the function body.
2. 10
3. Notice regarding pass by reference
4. 50
5. 5
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

singleton design pattern.

Question : In a situation where you want one and only one instance of a particular object, the ________ design pattern should be used.

Answer : Singleton design pattern.
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

variables in php

variables in php must start with _ or any alphabet but can contain number in it. but we can use curly braces to hold a variable that starts with a numeric characters. lets see a zend mock question for php 5 certification preparation.

Question : Which of the following are valid PHP variables?

Answer:

1. @$foo
2. &$variable
3. ${0x0}
4. $variable
5. $0x0
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

passing object in functions in php 5

Question : In PHP 5 you can use the ______ operator to ensure that an object is of a particular type. You can also use _______ in the function declaration.

Answer:

1. instanceof, is_a
2. instanceof, type-hinting
3. type, instanceof
4. ===, type-hinting
type-hinting ensures that we are passing a particular type of parameter to a function.
5. ===, is_a
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

fetching next result in pdo

Question : The ________ method in the PDOStatement class is used to return the next result set in a multi-query statement.

Answer: fetch -- this function fetches the next row of the result set.
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

concating 2 strings .

implode function and . operator are used to represent an array into string and concate 2 strings. lets see a zend mock question in this regards.

Question :

Given the two values below, which of the following possiblities will print 10 foos20 bars?



Answer: (choose 2)

1. None of the above
2. implode("", array($var1,$var2));
3. $var1 . $var2
4. $var1 + $var2
this will produce 30.
5. All of the above
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

copying a object

Question: What is wrong with the following code?

setValue(10);
$a_copy->setValue(20);

?>


Answer:

1. You must use return &$newObj instead
2. There is nothing wrong with this code
3. duplicate() must accept its parameter by reference
4. You must use the clone operator to make a copy of an object
5. duplicate() must return a reference
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

representing a object as string in php 5

The __toString() magic method is called automatically when an object is represent as a string.

Question: The _______ method will be called automatically when an object is represented as a string.

Answer :

1. getString()
2. __get()
3. __value()
4. __toString()
5. __getString()
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

class constructor in php 5

In php 5, the __construct is the constructor of a class and __destruct is the destructor of the class.previously, in php 4 we are using the class name as a function as constructor of a class.let's see zend mock questions regarding this.


Question: When migrating the following code from PHP 4 to PHP 5, what should be changed?

_doSomething($param);
}

// Private method to MyClass
function _doSomething($param) {
/* Do something with $param */
}
}

class AnotherClass extends MyClass {

var $param = "foo";

function AnotherClass() {
parent::MyClass($this->param);
}
}

?>


Answer:

1. Access modifiers should be added to methods
If no access modifier is present, it treats the variable or method like public.
2. The Constructors for the objects should both be renamed to __construct
3. The use of the parent keyword has changed to 'super'
4. Constructors must have the same parameter lists
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

stream wrappers in php

By creating wrappers we can create user defined protocol for streams.

Question : _______ can be used to add additional functionality to a stream, such as implementation of a specific protocol on top of a normal PHP stream implementation.

Answer:

1. Buffered
2. Buckets
3. Wrappers
4. Filters
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

ZEND MOCK TEST :intersect function list in php 5

there are various kind of intersection functions in php. they are the followings----

array_intersect(array arr1,array arr2,...): it will return the values of arr1 that are in other arrays.
array_intersect_assoc: it will return the values of arr1 with index checking with other arrays.
array_intersect_key: computes comparisons using keys.
array_intersect_uassoc: computes comparisons using association but checking keys by a user function.
array_uintersect_assoc: computes comparisons using association but checking values by a user function.
array_intersect_ukey: computes comparisons using keys.
array_uintersect: computes comparisons using values by a user function.
array_uintersect_uassoc: computes comparisons using association but checking keys and values by a user function.

Question: The following code snippet displays what for the resultant array?

0, 3 => 2, 4 => 6);
$b = array(3 => 1, 4 => 3, 6 => 4);

print_r(array_intersect($a, $b));
?>

Answer:

1. 1 => 0
2. 1 => 3, 3 => 1, 4 => 3
3. 3 => 1, 3=> 2, 4 => 3, 4=> 6
4. 1 => 0, 3 => 2, 4 => 6
5. An empty Array
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

request superglobal array in php

The $_REQUEST superglobal array contains gpc variables.

Question: The $_REQUEST super global contains what?

Answer:

Data received from the session
Data received from Cookies
Data received from the server environment
Data received from HTTP POST
Data received from HTTP GET
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

sqlite performance improvement

lets see a zend mock question related to sqlite.

Question: Which of the following SQL statements will improve SQLite write performance?

Answer:

1. PRAGMA locking_mode = "Row";
2. PRAGMA count_changes = Off;
3. PRAGMA default_synchronous = Off;
4. PRAGMA default_synchronous = On;
5. PRAGMA locking_mode = "Table";
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

autoloading in php 5

it was a hassle to add every class at the beginning of a file to use it in it.php5 comes with a solution for this problem. we can use __autoload function for this purpose. it will automatically load the class.

Question: Rather than manually providing the class declaration for every class as you had to in PHP 4, in PHP 5 you can define the _________ function, which will give your script the opportunity to automatically find and load a particular class upon instanciation

Answer: __autoload
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

ZEND PREP :returning function in php

we can get a result from a function only by using return or echo keywords. so, if there is no return or echo,then the function will not give any output. let's zend mock certification question for php 5.

Question:

What is the output of the following?



Answer:

1. 0
2. 36
3. 6
4. 30
5. 5
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

builder pattern

Builder design pattern is a creational design pattern. this means it creates an object step by step. In simple, the builder pattern uses an abstract class which has some common functions in it. this class is called as builder.there is a class that implements the builder class which is called concretebuilder. there is another class called director class which creates object of conretebuilder class step by step.so the pattern structure will be like

abstruct class abstruct1
{

}

class concretebuilder extends abstruct1
{

}

class director extends concretebuilder
{

}
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

passing by reference in php

Passing a variable by reference will change the value of the variable.

Question : What is the output of the following?



Answer:

1. 50
2. 5
3. 95
4. 10
5. 100
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

ZEND MOCK :adding element at the beginning of an array

we can add elements at the beginning and at the end of an array in php.let's see a zend preparation questions for php 5 mock exam.


Question: Which function would you use to add an element to the beginning of an array?

Answer:

1. array_shift()
This function is used to remove element from the beginning of the array.
2. array_push();
This function is used to add element at the end of the array.
3. $array[0] = "value";
4. array_unshift()
This function is used to add element at the beginning of the array.
5. array_pop();
This function is used to remove element from the end of the array.
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

reassigning this in php 5

In php 5 you can't assign a variable to $this. It will produce a fatal error.

Question: What is wrong with the following code valid in PHP 4 but invalid in PHP 5?

reassign($b);

?>

Answer:

1. Reassigning $this in PHP 5 throws a fatal error
2. It is missing access restrictions (public,private,protected) required in PHP 5
3. Classes need to implement the OverLoad interface for this behavior in PHP 5
4. $b is now an object handle and the reassign() method needs to be declared pass-by-reference
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

ZEND MOCK TEST PREPARATION: comparison in php

php provides many ways to compare 2 variables. == operator doesn't check the type of the operands. it just compare the 2 operands with matching the type. === operator checks for the types of the operands also. If a string contains any numbers before having any characters in it like "1time", then === operator matches it with integer value "1". Any string without initial number are treated as 0 when converted to integer. let's see a zend mock question for php 5 certification.


Question: Which of the following comparisons will evaluate to true?

Answer:

1. 't' == t
2. 1 === "1time"
3. "top" == 0
4. "top" === 0
5. 1 == "1time"
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Saturday, August 1, 2009

viewing sent headers

Question: Consider the following function:

function redirect($url) {
// Check to make sure we haven't already sent
// the header:

if(???????) {
header("Location: $url");
}
}

?>
What conditional should replace the ????? above?

Answer:

1. !in_array("Location: $url", headers_list())
2. !header_exists("Location: $url")
3. !header_location($url)
4. $_SERVER['HTTP_LOCATION'] != $url
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide