<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PHP Interview Questions and answers&#187; Expert level Archives  &#8211; interview questions and answers</title>
	<atom:link href="http://www.phpinterviewquestions.com/category/php-interview-questions/expert-level-php-interview-questions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpinterviewquestions.com</link>
	<description>Prepare for your next php based interview with high confidence</description>
	<lastBuildDate>Mon, 26 Sep 2011 08:37:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Explain abstract class and its behaviour?</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/explain-abstract-class-and-its-behaviour/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/explain-abstract-class-and-its-behaviour/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 06:34:10 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Expert level]]></category>
		<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/?p=453</guid>
		<description><![CDATA[Abstract class is defined as a solitary entity, so other classes can inherit from it. An abstractÂ  class can not be instantiated, only the subclasses of it can have instances. Following is one of the best examples to explain the use of an abstract class and the behavior of it.

 class Fruit {
 private $color;

 [...]]]></description>
			<content:encoded><![CDATA[<p>Abstract class is defined as a solitary entity, so other classes can inherit from it. An abstractÂ  class can not be instantiated, only the subclasses of it can have instances. Following is one of the best examples to explain the use of an abstract class and the behavior of it.</p>
<pre class="brush: php;">
 class Fruit {
 private $color;

 public function eat() {
  //chew
 }

  public function setColor($c) {
   $this-&gt;color = $c;
  }
 }

 class Apple extends Fruit {
  public function eat() {
   //chew until core
  }
 }

 class Orange extends Fruit {
  public function eat() {
   //peel
   //chew
  }
 }
</pre>
<p>Now taste an apple</p>
<pre class="brush: php;">
$apple = new Apple();
$apple-&gt;eat();
</pre>
<p>What&#8217;s the taste of it? Obviously it&#8217;s apple</p>
<p>Now eat a fruit</p>
<pre class="brush: php;">
$fruit = new Fruit();
$fruit-&gt;eat();
</pre>
<p>What&#8217;s the taste of it? It doesn&#8217;t make any sense. does it? Which means the class fruit should not be Instantiable . This is where the abstract class comes into play</p>
<pre class="brush: php;">
abstract class Fruit {
 private $color;

 abstract public function eat()

 public function setColor($c) {
  $this-&gt;color = $c;
 }
}
</pre>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8695027799979044";
/* 336x280, created 3/4/10 */
google_ad_slot = "4291231574";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/explain-abstract-class-and-its-behaviour/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Write a small function to calculate n to the power of n?</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/write-a-small-function-to-calculate-n-to-the-power-of-n/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/write-a-small-function-to-calculate-n-to-the-power-of-n/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 10:56:34 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Expert level]]></category>
		<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[PHP recursion]]></category>
		<category><![CDATA[pow]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/?p=446</guid>
		<description><![CDATA[In the above question the interviewer is expecting the logic behind the scene (Recursive). Actually he may directly ask you to write a recursive function to calculate N to the power of N, or given number to the power of N. Following is the simplest way that you can write a PHP recursive function for [...]]]></description>
			<content:encoded><![CDATA[<p>In the above question the interviewer is expecting the logic behind the scene (Recursive). Actually he may directly ask you to write a recursive function to calculate N to the power of N, or given number to the power of N. Following is the simplest way that you can write a PHP recursive function for this functionality.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8695027799979044";
/* 336x280, created 3/4/10 */
google_ad_slot = "4291231574";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: php;">

function MyPow($r, $w){
 if($w==0)
  return 1;
 else
  return MyPow($r, $w-1) * $r;
}

echo MyPow(10, 2);
</pre>
<p>Also this functionality substitutes by the <a title="PHP.net" href="http://php.net/manual/en/function.pow.php" target="_blank">pow()</a> function in PHP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/write-a-small-function-to-calculate-n-to-the-power-of-n/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What are the two new error levels introduced in PHP5.3?</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/php-error-levels-php5-3/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/php-error-levels-php5-3/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 10:43:25 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Expert level]]></category>
		<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[Deprecated]]></category>
		<category><![CDATA[Error levels]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/?p=408</guid>
		<description><![CDATA[E_DEPRECATED
The E_DEPRECATED error level is used to indicate that a function or feature has been deprecated.
E_USER_DEPRECATED
The E_USER_DEPRECATED level is intended for indicating deprecated features in user code, similarly to the  E_USER_ERROR and E_USER_WARNING levels.




]]></description>
			<content:encoded><![CDATA[<h3>E_DEPRECATED</h3>
<p>The <strong><tt>E_DEPRECATED</tt></strong> error level is used to indicate that a function or feature has been deprecated.</p>
<h3>E_USER_DEPRECATED</h3>
<p>The <strong><tt>E_USER_DEPRECATED</tt></strong> level is intended for indicating deprecated features in user code, similarly to the  <strong><tt>E_USER_ERROR</tt></strong> and <strong><tt>E_USER_WARNING</tt></strong> levels.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-8695027799979044";
/* 468x15, created 4/16/10 */
google_ad_slot = "1994287074";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/php-error-levels-php5-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Late static binding php5</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/late-static-binding-php5/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/late-static-binding-php5/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 08:01:02 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Expert level]]></category>
		<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[php5.3]]></category>
		<category><![CDATA[static binding]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/?p=391</guid>
		<description><![CDATA[




class A {
    public function who() {
        echo __CLASS__;
    }
    public function test() {
        $this-&#62;who();
    }
}

class B extends A {
    public function who() {
   [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-8695027799979044";
/* 336x280, created 3/4/10 */
google_ad_slot = "4291231574";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<pre class="brush: php;">
class A {
    public function who() {
        echo __CLASS__;
    }
    public function test() {
        $this-&gt;who();
    }
}

class B extends A {
    public function who() {
        echo __CLASS__;
    }
}
$obj = new B;
$obj-&gt;test();
</pre>
<p><strong>Out put of the above snippet is? B</strong> This is mainly because we have the object instance named as $this is for the class B, though the function is instantiated inside class A. But, If you need the expected output which is &#8220;A&#8221;, we can call them statically as follows </p>
<pre class="brush: php;">class A {
    public static function who() {
        echo __CLASS__;
    }
    public static function test() {
        self::who();
    }
}

class B extends A {
    public static function who() {
        echo __CLASS__;
    }
}

B::test();
</pre>
<p><strong>Out put -&gt; A</strong></p>
<p>Main limitation of self:: or __CLASS__ are resolved using the class in which the function belongs, as in where it was defined. By introducing <strong>late static binding</strong> this limitation has been resolved as follows,</p>
<pre class="brush: php;">
class A {
    public static function who() {
        echo __CLASS__;
    }
    public static function test() {
        static::who(); // Here comes Late Static Bindings
    }
}

class B extends A {
    public static function who() {
        echo __CLASS__;
    }
}

B::test();
</pre>
<p><strong>Out put -&gt; B</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/late-static-binding-php5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passive Iteration</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/passive-iteration/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/passive-iteration/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 10:49:29 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Expert level]]></category>
		<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[array_combine]]></category>
		<category><![CDATA[array_walk]]></category>
		<category><![CDATA[array_walk_recursive]]></category>
		<category><![CDATA[Iteration]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/?p=49</guid>
		<description><![CDATA[What will be the out put of the following code snippet ?
&#60;?php
function setcase(&#38;$value, &#38;$key){
$value = strtoupper($value);
}
$type = array('internal','external');
$format[] = array('rss','html','xml');
$format[] = array('csv','jason');
$map = array_combine($type, $format);
array_walk_recursive($map, 'setcase');
print_r($map);
?&#62;
Only scalar values will be converted to upper cases. &#8216; internal&#8217; and &#8216;external&#8217; are not passed into the user defined function.
Array
(
    [internal] =&#38;gt; Array
    [...]]]></description>
			<content:encoded><![CDATA[<p>What will be the out put of the following code snippet ?</p>
<pre class="brush: php;">&lt;?php
function setcase(&amp;$value, &amp;$key){
$value = strtoupper($value);
}
$type = array('internal','external');
$format[] = array('rss','html','xml');
$format[] = array('csv','jason');
$map = array_combine($type, $format);
array_walk_recursive($map, 'setcase');
print_r($map);
?&gt;</pre>
<p>Only scalar values will be converted to upper cases. &#8216; internal&#8217; and &#8216;external&#8217; are not passed into the user defined function.</p>
<pre class="brush: php;">Array
(
    [internal] =&amp;gt; Array
        (
            [0] =&amp;gt; RSS
            [1] =&amp;gt; HTML
            [2] =&amp;gt; XML
        )

    [external] =&amp;gt; Array
        (
            [0] =&amp;gt; CSV
            [1] =&amp;gt; JASON
        )

)
</pre>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8695027799979044";
/* 468x15, created 4/16/10 */
google_ad_slot = "1994287074";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/passive-iteration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regular expressions</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/expert-level-php-interview-questions/regular-expressions/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/expert-level-php-interview-questions/regular-expressions/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 05:19:03 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Expert level]]></category>
		<category><![CDATA[Regex]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/wordpress/?p=22</guid>
		<description><![CDATA[How can we extract string â€˜phpinterviewquestionsâ€˜ from a string â€˜http://phpinterviewquestions.comâ€™ using regular expression of PHP?
preg_match(&#8216;/http://([wW]+?).com/i&#8217;,'http://phpinterviewquestions.com&#8217;,$out);
echo $out[1];
]]></description>
			<content:encoded><![CDATA[<p>How can we extract string â€˜phpinterviewquestionsâ€˜ from a string â€˜http://phpinterviewquestions.comâ€™ using regular expression of PHP?</p>
<p>preg_match(&#8216;/http://([wW]+?).com/i&#8217;,'http://phpinterviewquestions.com&#8217;,$out);<br />
echo $out[1];</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/expert-level-php-interview-questions/regular-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Object  Orientation with PHP5</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/expert-level-php-interview-questions/object-orientation-with-php5/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/expert-level-php-interview-questions/object-orientation-with-php5/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 05:19:03 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Expert level]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/wordpress/?p=29</guid>
		<description><![CDATA[What are the differences between abstract class and interface?
Abstract class: abstract classes are the class where one or more methods are abstract but not necessarily all method has to be abstract. Abstract methods are the methods, which are declare in its class but not define. The definition of those methods must be in its extending [...]]]></description>
			<content:encoded><![CDATA[<p>What are the differences between abstract class and interface?</p>
<p>Abstract class: abstract classes are the class where one or more methods are abstract but not necessarily all method has to be abstract. Abstract methods are the methods, which are declare in its class but not define. The definition of those methods must be in its extending class.<br />
<br />
Interface: Interfaces are one type of class where all the methods are abstract. That means all the meth</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/expert-level-php-interview-questions/object-orientation-with-php5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Predefined classes in PHP</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/expert-level-php-interview-questions/predefined-classes-in-php/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/expert-level-php-interview-questions/predefined-classes-in-php/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 05:19:03 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Expert level]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[predefined classes]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/wordpress/?p=32</guid>
		<description><![CDATA[List out the predefined classes in PHP?
Directory
stdClass
__PHP_Incomplete_Class
exception
php_user_filter




Best way to check your reserved classes is,
var_dump (get_declared_classes ());
Standard Defined Classes
These classes are defined in the standard set of functions included in the PHP build.
Directory
    The class from which dir is instantiated.
stdClass
    Created by typecasting to object.
__PHP_Incomplete_Class
    Possibly created [...]]]></description>
			<content:encoded><![CDATA[<p>List out the predefined classes in PHP?</p>
<p><strong>Directory</strong></p>
<p><strong>stdClass</strong></p>
<p><strong>__PHP_Incomplete_Class</strong></p>
<p><strong>exception</strong></p>
<p><strong>php_user_filter</strong></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8695027799979044";
/* 468x15, created 4/16/10 */
google_ad_slot = "1994287074";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>Best way to check your reserved classes is,<br />
var_dump (get_declared_classes ());</p>
<p>Standard Defined Classes</p>
<p>These classes are defined in the standard set of functions included in the PHP build.</p>
<p><strong>Directory</strong><br />
    The class from which <a target="_blank" href="http://www.php.net/manual/en/class.dir.php">dir</a> is instantiated.<br />
<strong>stdClass</strong><br />
    Created by <a target="_blank" href="http://www.php.net/manual/en/language.types.object.php#language.types.object.casting">typecasting to object</a>.<br />
__<strong>PHP_Incomplete_Class</strong><br />
    Possibly created by unserialize(). </p>
<p>Predefined classes as of PHP 5</p>
<p>These additional predefined classes were introduced in PHP 5.0.0.</p>
<p><a target="_blank" href="http://www.php.net/manual/en/class.exception.php"><strong>exception</strong></a><br />
<strong>php_user_filter</strong> </p>
<p><strong>Closure</strong></p>
<p>The predefined final class <strong>Closure</strong> was introduced in PHP 5.3.0. It is used for internal implementation of <a target="_blank" href="http://www.php.net/manual/en/functions.anonymous.php">anonymous functions</a>.</p>
<p>The class has a constructor forbidding the manual creation of the object (issues E_RECOVERABLE_ERROR) and the __invoke method with the <a target="_blank" href="http://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.invoke">calling magic.</a></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8695027799979044";
/* 336x280, created 3/4/10 */
google_ad_slot = "4291231574";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/expert-level-php-interview-questions/predefined-classes-in-php/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Abstract class and interface?</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/expert-level-php-interview-questions/abstract-class-and-interface/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/expert-level-php-interview-questions/abstract-class-and-interface/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 05:19:03 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Expert level]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/wordpress/?p=33</guid>
		<description><![CDATA[What are the differences between abstract class and interface?
Abstract class: abstract classes are the class where one or more methods are abstract but not necessarily all method has to be abstract. Abstract methods are the methods, which are declare in its class but not define. The definition of those methods must be in its extending [...]]]></description>
			<content:encoded><![CDATA[<p>What are the differences between abstract class and interface?</p>
<p><i>Abstract class:</i> abstract classes are the class where one or more methods are abstract but not necessarily all method has to be abstract. Abstract methods are the methods, which are declare in its class but not define. The definition of those methods must be in its extending class.</p>
<p><i>Interface:</i> Interfaces are one type of class where all the methods are abstract. That means all the methods only declared but not defined. All the methods must be define by its implemented class.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/expert-level-php-interview-questions/abstract-class-and-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

