Friday, July 31, 2009

zend php 5 certification : filtering input

We should not trust any input from any source.The source could be a user, url or database value, any thing. Every input data must be filtered. unfiltered data makes your system vulnerable to attacks. php offers many input filtering functions. Let's a mock zend php 5 certification question regarding this.


Question : What is the best way to ensure the distinction between filtered / trusted and unfiltered / untrusted data?

Answer:

1. None of the above
2. Never trust any data from the user
3. Enable built-in security features such as magic_quotes_gpc and safe_mode
4. Always filter all incoming data
5. Use PHP 5's tainted mode
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

Thursday, July 30, 2009

short introduction to jmeter

Now let’s see how the process to install jmeter. You can download it from http://jakarta.apache.org/site/downloads/index.html. You need Java 4 or newer to run jmeter. After unzipping click the jmeter.bat under bin folder.

1. First of all, by right clicking on the workbench we can add a HTTP proxy server.
2. Set the proxy server of the browser to localhost and the port to 8080.
3. Start the HTTP proxy server and reload the site that u want to test on your browser. You will see the changes in the jmeter. By clicking them, you will see the header sent for them. On clicking the header, you will see the header information. By click the page, you can edit the http data for the request. After loading the page, you need to stop the server.
4. Now we will make a test plan. We will make a thread group first by right clicking on it. In the thread group , you will see thread properties. Number of thread means the number of users that will try to see your site. Ramp-up period means the time interval between two successive users. If you set 0,this means the users access at the same time. Loop count is how many times the test will run.
5. Now we will add those section that we want to test. Right click on the section, that show site address without hostname. Select copy and paste it in thread group.
6. Now we will add some listener to see the test result. There are lots of listeners . I use graph result, monitor result, simple data writer, spine visualizer, summary report, view results in table, view results tree. I will explain the different uses of these listener later on.
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

unit test in software development.

Regression testing is performed after the software quality assurance team has done their work perfectly. And of course, after the developers have done the unit testing which means testing a class independently in object oriented environment or a procedure or method in procedural environment. Unit test is used to test whether an independent piece of code is working properly and if an error occurs, a developer can easily identify the problem. This kind of testing is very helpful. It follows the bottom-up approach of testing that means first checking the smallest chunk of code independently and then check with other parts integrated. Unit test case can be made with the available UML tool these can be found as an extension to an IDE. With the unit-test design method, the tests will never pass if the developer does not implement the solution according to the design. To obtain the fruit of unit testing, the software process must follow the steps of software development.
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

regression testing with jmeter.

Jmeter is a regression testing tool. Software regression means a software bug that makes a feature stop which was working correctly earlier. Sometimes a feature gets too much slow or uses too much memory. Regressions are generally caused due to encompassed bugs. Encompassed bugs are not a bug but a side effect of some critical issues. So, to handle these bugs we need to have some test plan. Software regression mainly occurs for one of the following three reasons. They are-
1. Local – a change introduces a new bug that was not before.
2. Remote – a change in one part of the software that introduces a new bug in other parts.
3. Unmasked – a change unmasks an already existing bug that was not there before.
So, regression tests composed of tests which will check the effectiveness of the site. These things are tested using Jmeter. Jmeter tests a site by running a site concurrently for several times.
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

Wednesday, July 29, 2009

Zend PHP 5 Certification Mock Exam: pdo dsn

Question:

Which of the following is not a valid PDO DSN?

Answer:

1. All of the above are valid
2. mysql:unix_socket=/tmp/mysql.sock;dbname=testdb
3. oci:dbname=//localhost:1521/mydb
4. mysql:host=localhost;port=3307;dbname=testdb
5. sqlite2:/opt/databases/mydb.sq2
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

session related question in zend mock test for zend php 5 certification

Question: When implementing a permissions system for your Web site, what should always be done with regards to the session?

Answer:

1. None of the above
2. You should not implement permission systems using sessions
3. Sessions should be cleared of all data and re-populated
4. The session key should be regenerated

5. The session should be destroyed
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

array walk function

array_walk_recursive(array & input,callback func[, mixed userdata]) to walk with a callback function recursive.

Question:

Which key will not be displayed from the following code block?


$array = array('a' => 'John',
'b' => 'Coggeshall',
'c' => array('d' => 'John',
'e' => 'Smith'));

function display($item, $key) {
print "$key => $item\n";
}

array_walk_recursive($array, "display");

?>

Answer:

1. d
2. c
any key that contains an array will not be shown.
3. b
4. a
5. They all will be displayed
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

transaction in php

Question:

Which of the following cases are cases when you should use transactions?

Answer:

1. Updating a single row in a table
2. Inserting a new row into a single table
3. Performing a stored procedure
4. Selecting rows from multiple different tables
transaction is not use in select statement.
5. Updating a single row in multiple different tables
transaction is used in multiple tables for updating process.
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

combine 2 arrays

array_combine(array keys,array values): will return an array where 1st array will be the key and the 2nd array will be the value. this is new in php5.

array_reverse(array input[,bool preserve_keys]) will reverse the input array.

Question:

What should go in the missing line ????? below to produce the output shown?

$array_one = array(1,2,3,4,5);
$array_two = array('A', 'B', 'C', 'D', 'E');

???????

print_r($array_three);
?>
Result:

Array
(
[5] => A
[4] => B
[3] => C
[2] => D
[1] => E
)


Answer:

1. $array_three = array_merge(array_reverse($array_one), $array_two);
2. $array_three = array_combine($array_one, $array_two);
3. $array_three = array_combine(array_reverse($array_one), $array_two);
4. $array_three = array_merge($array_one, $array_two);
5. $array_three = array_reverse($array_one) + $array_two;
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

extracting substring

lets see a zend mock question regarding extracting substring.

Question:

Given the string:
$var = "john@php.net";
Which of the following will extract the TLD (top level domain) of ".net" from the string?


Answer:

1. strstr($var, strpos($var, "."));
the second parameter of strstr is the needle.

2. substr($var, strpos($var, "@"));
3. substr($var, strstr($var, "."));
the second parameter of substr is the offset.
4. substr($var, strpos($var, ".") + 1);
it will extract net.
5. substr($var, strpos($var, "."));
it will extract .net
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

pass by reference in php 5

let's see a zend mock test question for php 5 certification.

Question:

Consider the following script:


This code has changed behavior in PHP 5. Identify the output of this script as it would have been in PHP 4, as well as the new behavior in PHP 5.


Answer:

1. array('a', 'a', 'b')
2. array('a', 'b', 'c')
This will show in php 5.
3. array('c', 'b', 'a')
4. array('c', 'c', 'c')
I think this will be the result for php 4.
5. array('b', 'b', 'b')
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

destroying session varriables

Question:

To destroy one variable within a PHP session you should use which method in PHP 5?

Answer:

1. Unset the variable in $HTTP_SESSION_VARS
2. Use the session_destroy() function
this function destroy all session varriable in the current session. but not unregister them.
3. Use the session_unset() function
this will unregister all the session varriables.
4. unset the variable in $_SESSION using unset()
this will unregister the session varriable.
5. Any of the above are acceptable in PHP 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

placing include files

users can easily access files that are in the document root. so, it is safe to place configuration and log files outside of the document roots. and you can use those file by using include/require or better to use include_once/require_once.Lets see zend mock questions regarding this.

Question:

Where should indirectly executed PHP scripts (i.e. include files) be stored in the file system?

Answer:

1. Outside of the Document Root
2. In the document root
3. Anywhere you want
4. In the database
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

xpath query in php

Lets see the zend mock php 5 certification question on xpath.

Question:

Consider the following simple PHP script:


$dom = new DomDocument();
$dom->load('test.xml');
$xpath = new DomXPath($dom);
$nodes = $xpath->query(???????, $dom->documentElement);
echo $nodes->item(0)->getAttributeNode('bgcolor')->value
. "\n";

What XPath query should go in the ?????? above to display the "bgcolor" attribute of the first "body" node in the XML document?


Answer:

1. "*[local-name()='body']"
2. "/body[0]/text"
3. "/body/body[0]"
4. "name='body'"
I am not sure about this. my answer is this.
5. "*[lname()='body']"
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

static keyword in php 5

Static varriables and constants are accessed by the scope resolution operator. But it will not show any errors. If you set the error level to E_STRICT, then it will show an error.


Question:

Consider the following PHP 4 code snippet:

value = $value;
}

function doSomething($myClass) {
$myClass->setValue(10);
}
}

$myClass = new MyClass();
MyClass::doSomething($myClass);
?>
In PHP 5, will this code change behavior? Why or why not?

Answer:

1. No, Not unless E_STRICT is enabled
2. Yes, you have to declare doSomething() static now
3. Yes, objects are now reference based
4. No, it will function exactly the same
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

varriable in

php varriables remain as the varriable within a single quote, but in double quotes they have their values in them. We can use curly braces in double quotes for using with varriable.

Question:

Which of the following are not valid ways to embed a variable into a string?

Answer:(choose 2)

1. $a = "Value: $value->getValue()";
I am not sure about this.
2. $a = "Value: {$value}";
3. $a = 'Value: $value';
it will output Value: $value.
4. $a = "Value: $value";
5. $a = "Value: {$value['val']}";
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

output xml string

The asXml([string filename]) returns a well-formed xml string to the output. If a filename is specified then it is written to the file.


Question:

Given the following PHP script:



$xmldata = XML
?xml version="1.0" encoding="ISO-8859-1" ?
!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
head
title XML Example/title
/head
body
p
b Hello, World! /b
/p
/body
/html
XML;

$sxe = simplexml_load_string($xmldata);

$p = $sxe->body->p;

$string = ????????

print $string;



What should go in place of ????? above to print the string Hello, World! (with no leading/trailing whitespace or markup)?


Answer:

1. trim(($p[1]));
2. trim(strip_tags(($p->asText())));
There is no such function named asText()
3. trim(strip_tags(($p->asXML())));
4. trim(($p->asXML()));
5. strip_tags(($p->asXML()));
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

xml dtd

Question:

What XML technology is used when you mix two different document types in a single XML document?

Answer:

1. Validators
2. DTD
DTD describes the document type definition of a xml document.
3. Transformations
4. Namespaces
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

hashing in php

First of all, i don't know what is fingerprint. but i think the question was asking about hashing a string. and there are lots of ways in php that will help us hashing a string. but hash(string algo,string string[,bool raw_outputs]) is the most appropriate for this as this function can use different algorithms for hashing.this functin is new in php 5.

Question:
A fingerprint of a string can be determined using which of the following?

Answer:

1. md5()
2. hash()
3. fingerprint()
no such function.
4. None 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

setting timeout in streams

Question:
The ____________ function is used to modify the amount of time PHP will wait for a stream before timing out during reading or writing.

Answer:

stream_set_timeout(resource stream,int sec[,int microsec=0]) sets the timeout period.
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 name

In php, a function name can be alphanumeric and underscore. but the first character can't be a number. let's see the zend mock question for this.

Question:

What is the output of the following?

function 1dotEach($n)
{
if ($n > 0)
{
1dotEach(--$n);
echo ".";
}else
{
return $n;
}
}
1dotEach(4);
?>


Answer:

1. ....0
2. Parse Error: Syntax Error
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 attribute

we can set different attributes on pdo. let's see zend mock question for this .

Question:

When writing portable database code using PDO, what is the PDO::ATTR_CASE attribute useful for?

Answer:

1. None of the above
2. Ensuring that all columns are of a particular case when fetched
3. Adjusting the case of a query before it is processed for compatibility reasons
4. Controls the switch logic of how queries are processed
5. Allows you to adjust the memory cache (or "case") for increased performance
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

xml question

The following is question regarding xml. I am not sure of the answers.

Question:

Consider the following example XML document:

?xml version="1.0" encoding="ISO-8859-1" ?
!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
head
title XML Example /title
/head
body
p
Moved to a href="http://example.org/" http://www.example.org//a.
br
/p
/body
/html
What is wrong with this document, and how can it be corrected?


Answer: (choose 2)

1. The document is completely valid
2. All special XML characters must be represented as entities within the content of a node
3. All tags must be closed
4. You cannot specify a namespace for the html attribute
This is not right. one can specify a namespace for the html attribute.
5. The DOCTYPE declaration is malformed
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

reverse a string in php

Let's see the zend mock test question.

Question:

Which functions would be needed to translate the following string:
I love PHP 5
to the following?
5 PHP EVOL I

Answer:(choose 2)

1. mirror()
2. strtoupper()
it will convert the string to uppercase.
3. toupper()
4. str_reverse()
5. strrev()
it will reverse the string.
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

octal and hexadecimal values in php

For calculating octal numbers the formula is
$a=010

$a=1x8^1+0x8^0=8

For hexadecimal values

$b=0xA

$b=10

Here A=10,...,F=15.

Question :
What is the output of the following?


$a = 010;
$b = 0xA;
$c = 2;

print $a + $b + $c;

?>

Answer:

1. 20
2. 22
3. 18
4. $a is an invalid value
5. 2
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

handling cross-site request forgery

csrf exploits the trust of application on user. csrf attacks are best way to handle by sending a form with post method. There can be a way to prevent csrf with adding a secret token in form hidden field.


Question : What is the best measure one can take to prevent a cross-site request forgery?

Answer:

1. Disallow requests from outside hosts
2. Add a secret token to all form submissions
3. Turn off allow_url_fopen in php.ini
4. Filter all output
5. Filter all input
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

array element in php

Let's see zend php 5 mock test question regarding arrays below.

Question:
What is the output of the following code?


$string = "14302";

$string[$string[2]] = "4";

print $string;

?>

Answer:

1. 14304
2. 14342
3. 44302
4. 14402
5. 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

spliting a string in php

There are several functions in php to split a string.

1. The simplest and most efficient is to use explode(string delimiter,string str[,int limit]) function.

2. we can use str_split(string str[,int length]). this function split a string with each being upto specified length.This is new in php 5.

3.split(string pattern,string string[,int limit]) functions splits a string with pattern and the array size will be upto limit size with the last one containing the rest of the string.

4.preg_split(string pattern,string str[,int limit[,int flags]]) returns an array containing the matched substrings upto limit number of arrays.
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

split a string.

let's see the zend mock exam question related to splitting a string in php.

Question: Which of the following is the best way to split a string on the "-=-" pattern?

Answer:

1. They all are equally proper methods
2. str_split($string, strpos($string, "-=-"))
3. preg_split("-=-", $string);
4. explode("-=-" $string);
it doesn't have 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

php streams features

streams in php has the following properties.

1. streams uses less memory and can handle large data.
2. streams are accessed like files.
3. streams are sometimes seekable.
4. streams may be unidirectional.
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 class

let's see a question of zend certification mock test regarding stream's feature.

Question: Which of the following are not true about streams?

Answer:

1. They are always seekable
2. When used properly they significantly reduce memory consumption
3. They can be applied to any data source
4. They are always bi-directional
5. They can be filtered
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

retrive the function arguments in php

The func_get_args() function returns an array of argument that a function has in it's parameter list. There are also func_num_args() and func_get_arg() functions which can be used to get function parameter information. let's see zend mock certification test question below.

Question:
What would you replace ??????? with, below, to make the string Hello, World! be displayed?



Answer:

1. There is no way to do this
2. $string = $argv[1];
3. $string = $_ARGV[0];
This will return the script name.
4. list($string) = func_get_args();
5. $string = get_function_args()
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

strip_tags function for php

php provide a function named strip_tags(string str[,array allowable_tags]). we can strip html tags using this function. But this is function is not safe totally as the allowable_tags parameter will can those tags that will not be stripped off. So, we can totally rely on strip_tags for input filtering and output escaping. Let's the zend mock question for php 5 certification.

Question: When using a function such as strip_tags, are markup-based attacks still possible?

Answer:

1. No, HTML does not pose any security risks
2. Yes, even a

HTML tag is a security risk
3. Yes, attributes of allowed tags are ignored
strip_tags does not strip allowable tags.
4. No, strip_tags will prevent any markup-based attack
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

Tuesday, July 28, 2009

file access in php security.

In php we have doc_root,user_dir and open_basedir option to control file access using php.If we Specify the doc_root,then every request for opening a file will be checked against the doc_root.If it is not under the doc_root, the request is discarded.Another one is user_dir. user_dir is used with respect to doc_root.If a user_dir is specified then a request is checked whether the file is in the doc_root and then is it in the user_dir. open_basedir controls which files will be opened using php. we must use a trailing slash after the file name to be more secure.
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

displaying errors in a site.

Error message shows mainly database related error messages. Lets see the mock zend php certification question.

Question: Why is it important from a security perspective to never display PHP error messages directly to the end user, yet always log them?

Answer:(choose 2)

1. Error messages will contain sensitive session information
session information are not shown in a error message.
2. Error messages can contain cross site scripting attacks
xss attack is not possible with such error message.
3. Security risks involved in logging are handled by PHP
4. Error messages give the perception of insecurity to the user
5. Error messages can contain data useful to a potential attacker
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

output buffering

There will be no output before any headers are sent.But we can use output buffering to sent headers. The output code will be between ob_start and ob_clean functions. Let's see the mock zend certification test question.

Question: One can ensure that headers can always be sent from a PHP script by doing what?

Answer:

1. Enable header buffering in PHP 5
2. Set the header.force INI directive to true
3. Enable output buffering in PHP 5
4. There is no way to ensure that headers can always be set, they must always be checked
5. None 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

static methods in php

Static methods can be accessed by self keyword within the class and we can't use this keyword. Let's see the mock zend certification test question.

Question: What is the primary difference between a method declared as static and a normal method?

Answer:

1.Static methods can only be called using the :: syntax and never from an instance
2.Static methods do not provide a reference to $this
3.Static methods cannot be called from within class instances
4.Static methods don't have access to the self keyword
5.There is no functional difference between a static and non-static method
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

array index

Array index can be string or integer. The following a problem regarding array index. Let's see the mock zend certification test question.

Question:
What is the output of this code snippet?


$a = array(0.001 => 'b', .1 => 'c');

print_r($a);

?>

Answer:
1. An empty array
2. 0.001 => 'b', .1 => c
3. 0 => 'c'
Because the fractional part will be converted to the nearest integer.
4. '0.001' => 'b', '0.1' => c'
5. A Syntax Error
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

object comparison

Object comparison has got some change in php 5. Object comparison using === operator will mean that 2 objects are of same instance of a class, where as using == operator means the 2 objects have same attribute and value and of the same class. This is will be helpful for zend php certification. Let's see a mock test question. The bold one is my answer , you can give yours in comment.

Question: what compatibility problem will this conditional has in php5 .

if($obj1==obj2){}

Answer:

1.This code is undefined in PHP 4
2.None of the above
3.$obj1 and $obj2 must have the same property values in PHP 5 .

This is true for == operator.
4.$obj1 and $obj2 must be the same instance in PHP 5 .

this is right answer.
5.There are no compatibility issues
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 features.

Sqlite is a popular lightweight faster database. There will be some question regarding sqlite in zend certification exam. There are some features of sqlite below-
  • It is transactional means it has the ACID propertis.
  • It has zero-configuration setup means it needs no configurations for setup.
  • It can store upto terabyte sized databases and gigabyte sized strings.
  • Sqlite is faster compare to other databases.
  • It has simple, easy to use api.
  • complete database is stored in a disk file.
  • use less memory and bandwidth.
  • it does not support foreign keys.
  • types are assigned to values.
  • concurrent read is possible, but concurrent write is not possible.
  • this is not a client-server database.
  • the data are read as numeric and textual.
Drawbacks:
  • it does not support domain integrity.
Some uses of sqlite is stated below--

  • we can use it for writing xml data to files. It will then support transactional properties, cross platform and avoid the hassles of parsing.
  • it is used in mobile phone, PDA and other electronic gadgets.
  • it is popular with small and medium-sized websites.
  • it can be used for testing sites.





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

make fun with streams

Streams help us to read and write file systems. PHP provide us some functions. I am giving some short description for some stream functions. These are important for zend php certification exam.

1.stream_wrapper_register(string protocol,string classname[,int flags]): This function is used to register user defined wrappers.

the protocol is the wrapper name, classname is the classname that will define the wrapper and the flag says whether it is defined by the url.

2.stream_wrapper_restore(string protocol): This function restores a previously unregistered built-in wrapper. This is new in php 5.

3.stream_wrapper_unregister(string protocol): This function unregister a wrapper. This is new in php 5.

4.stream_context_create([array options[,array params]]): creates a context with options and params.

5.stream_context_set_option(resource context,array options): set options.

6.steam_context_set_params(resource context,array options): set params.

7.stream_context_set_default(array options): set options for default context.This is new in php 5.

8.stream_context_get_default([array options]): get the default context.This is new in php 5.

9.stream_copy_to_stream(resource source,resource dest[,int maxlength=-1[,int offset=0]]):copies stream .This is new in php 5.

10.stream_filter_register(string filtername,string classname): register a user defined filter. the class has onCreate(),onClose,filter functions.

11.stream_filter_prepend/append(resource stream,string filter[,int read_write[,mixed params]]): prepend a filter. The read_write parameter could be STREAM_FILTER_READ,STREAM_FILTER_WRITE,STREAM_FILTER_BOTH.The params will be prepended at the beginning of the stream.

12.stream_get_filters(): get list of filters. This is new in php 5.

13.stream_get_wrappers(): get list of wrappers. This is new in php 5.

14.stream_get_transports(): get list of transports. This is new in php 5.

15.stream_get_meta_data(resource stream): returns information of the current stream. It contains whether the stream is blocked, time out , how much is left for reading,seekable, stream mode, wrapper data type,filter, end of file. This function does not work on sockets.

16.stream_get_line(resource handle,int length[,string end]): gets line from the given handle upto a string end without the end string. This is new in php 5.

17.stream_filter_remove(resource stream_filter):removes the filter added before. This is new in php 5.

18.stream_get_contents(resource handle[,int maxlength[,int offset]]): gets the remaining contents of the stream. This function works on a open file stream.This is new in php 5.

19.stream_is_local(resource handle): checks whether it is local or a url.This is new in php 5.

20.stream_notification_callback(): a callback function for notification context parameter.This is new in php 5.

21.stream_select(array &read,array &write,array & except,int tv_sec[,int tv_usec=0]): This function accepts an arrays of streams and waits for status. It returns the streams that are available within the time out seconds.

22.stream_set_blocking(resource stream,int mode): sets blocking/non-blocking mode.

23.stream_set_timeout(resource stream,int sec[,int usec=0]):set timeout period,expressed in the sum of sec and usec.




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, July 27, 2009

pdo setAttribute function

The pdo function setAttribute(int attribute,mixed value) sets different attributes on database connection. The attributes are the followings-

1. ATTR_CASE : sets the case of the column names.
2. ATTR_ERRMODE: error reporting.
3. attr_stringify_fetches: converts numeric values to strings when fetching.
4.attr_statement_class: sets the user supplied statement class using pdostatement class.
5.attr_autocommit: whether to autocommit.
6.MYSQL_ATTR_USE_BUFFERED_QUERY: use buffered query.




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

Simple API for XML

SAX means simple api for xml. It is built with java first. It is event-based xml parsing method.Dom uses tree-based xml parsing method. Dom parses the whole tree first. So, it can move to any position to change the data. Below are some properties of SAX.

1. It is event-based.
2. SAX can't move backward. It is unidirectional.
3. SAX can process data before loading the complete data.
4. It consumes less memory than DOM.




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

Testing with jmeter

We can test a site's performance using jmeter. Though we can get the same functionality by firebug, but firebug shows the statistics for only one request, where jmeter shows for several users.

To use jmeter first you need to download the latest version from the web. Your need java 4 or latter to be installed in your machine to install jmeter. You need jre also. You have to set the path of jre as the system variable. After unziping the folder, click the jmeter.bat under bin folder. It will open the jmeter. Under the workbench, create proxy http server by right clicking it.You have to change the proxy settings of the browser by going to tools, then options, choose manual proxy settings.Enter localhost and port is 8080. Then restart the website that you want to test. you will see some changes in the jmeter window. Now under test plan , create thread group by right clicking. Then from the listed enteries of the testing site, only copy the section that is for the page, don't take any image,js, css files, that will make huge load for ur testing. Now add some listeners. you can add graph,summary result etc to see the results. And under the thread group, change the number of users to 100 or the number u want to test. This shows the number of users that are concurrently accessing the site.

You can view the result in the listeners. If you want to make another test, just clear all the results.




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, July 11, 2009

With DOM (document object model), we can add or remove a node in xml with DOM. DOM comes up with many powerful features. Let see the question now for preparation of ZEND certification test. The bold options are the answers. You can give your opinion about the answers.
Question: What should go in the missing line ????? below to produce the output shown?

$array_one = array(1,2,3,4,5);
$array_two = array('A', 'B', 'C', 'D', 'E');

???????

print_r($array_three);

Result:

Array
(
[5] => A
[4] => B
[3] => C
[2] => D
[1] => E
)

a. $array_three = array_merge(array_reverse($array_one), $array_two);
b. $array_three = array_combine($array_one, $array_two);
c. $array_three = array_combine(array_reverse($array_one), $array_two);
This is the right answer.The array_combine function takes 2 arguments. One is keys and other is values. If the length of the arrays are not match or the array is empty , then E_WARNING is thrown.

d. $array_three = array_merge(array_reverse($array_one), $array_two);
e. $array_three = array_combine($array_one, $array_two);




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

Event-based XML parsing:

With DOM (document object model), we can add or remove a node in xml with DOM. DOM comes up with many powerful features. Let see the question now for preparation of ZEND certification test. The bold options are the answers. You can give your opinion about the answers.
Question: Event-based XML parsing is an example of which parsing model?
a.SAX
SAX is event-based xml parsing method.
b.DOM
DOM is tree-based xml parsing method.
c.XML Object Mapping
d.XPath
e.XQuery




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

Friday, July 10, 2009

Showing error info in PDO:

There are 3 values in the array that is returned by the errorinfo function in PDO.Let see the question now for preparation of ZEND certification test. The bold options are the answers. You can give your opinion about the answers.
Question: Consider the following PHP code segment, which attempts to execute a PDO query:

try {
$dbh->exec($sql);
} catch (PDOException $e) {
// display warning message
$info = $e->errorInfo;
}

In the event of a PDOException, $info is set with the contents of the $errorInfo property of the exception. Which of the following are accurate descriptions of the contents?

a.$info[1] is the database-specific error code
This is right.
b.$info[2] is the database-specific error message
This is right.
c.$info[1] is the unified error code
d.$info[0] is the unified error code
This is right.
e.$info[0] Is the Database-specific error message




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, July 8, 2009

Closing Tags in php code blog:

Php interpreter can recognize a php code block by it’s tags. When it founds a starting tags, then it knows that the flowings are the php code to process. You can omit the closing tags. This will not make any difference, rather it will help to avoid an error. If there is any white space after the closing tags, then php will throw an error. There are 4 php tags. Let see the question now. The bold options are the answers. You can give your opinion about the answers.
Question: Which of the following tags are an acceptable way to begin a PHP Code block?[choose 4]
a. "e;script language=”php”"e; "e;/script"e;
This is the javascript style php tag.
b. "e;!
This tag is invalid.
c. "e;%
This is ASP style tag.
d. "e;?php
This the default php tag.
e. "e;?
This is the short tag for php.




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, July 7, 2009

Arguments of a function

I will show you all a question regarding argument passing to a function in php. In php 5.3.0 we can assign NULL by reference to any argument. Now let’s see the question of ZEND mock test. The bold options are the answers. You can give your opinion about the answers.
Question: Which of the following is incorrect?[choose 4]
a. function c(MyClass $a = new MyClass())
You can't create an object of a class in this way.
b. function d($a = null)
php 5.3.0 gives option to set argument as null.
c. function e(&$a = 30)
You can’t assign default value to a parameter by reference.
d. function a(&$a = array(10,20,30))
Arrays can not be assigned to an argument.
e. function b($a = (10 + 2))
you can not assign an expression to an argument In a function.




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