<?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; PHP Questions Archives  &#8211; interview questions and answers</title>
	<atom:link href="http://www.phpinterviewquestions.com/category/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>What is the use of &#8220;Final class&#8221; and can a final class be an abstract?</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/what-is-the-use-of-final-class-and-can-a-final-class-be-an-abstract/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/what-is-the-use-of-final-class-and-can-a-final-class-be-an-abstract/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 10:46:32 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Advanced level]]></category>
		<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[abstract class]]></category>
		<category><![CDATA[oop]]></category>

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

The &#8220;Final&#8221; keyword is used to make the class uninheritable. So the class or it&#8217;s methods can not be overridden.

final class Class1 {
    // ...
}

class FatalClass extends Class1 {
    // ...
}

$out= new FatalClass();

An Abstract class will never be a final class as an abstract class must be extendable. 
]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-8695027799979044";
/* 468x60, created 1/27/11 text only */
google_ad_slot = "3922180179";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
The &#8220;Final&#8221; keyword is used to make the class uninheritable. So the class or it&#8217;s methods can not be overridden.</p>
<pre class="brush: php;">
final class Class1 {
    // ...
}

class FatalClass extends Class1 {
    // ...
}

$out= new FatalClass();
</pre>
<p>An Abstract class will never be a final class as an abstract class must be extendable. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/what-is-the-use-of-final-class-and-can-a-final-class-be-an-abstract/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>back to the basics</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/back-to-the-basics/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/back-to-the-basics/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 10:38:24 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[basics]]></category>

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

This is just a quick note about how you must prepare for your technical interview whether it&#8217;s a face to face or a written.
Before you prepare for a technical interview you must re-work on your basics in the first place. if you are not sure enough don&#8217;t go to the interview. Prepare well for your [...]]]></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>
<p>This is just a quick note about how you must prepare for your technical interview whether it&#8217;s a face to face or a written.<br />
Before you prepare for a technical interview you must re-work on your basics in the first place. if you are not sure enough don&#8217;t go to the interview. Prepare well for your next interview. It will help you a lotÂ  <img src='http://www.phpinterviewquestions.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>For an instance at least work on following aspects,</p>
<ul>
<li><strong>Client Server</strong>Â  &#8211; &gt; What is client server architecture? Basic requesting methods to the server?</li>
<li><strong>Sessions</strong>Â  -&gt; What is a session? Where sessions are stored? How session reference is carried in the browser(client) side?</li>
<li><strong>OOP</strong>Â Â Â Â  -&gt; What is a class? what is overloading? what is overriding and how you do these with examples?</li>
<li><strong>XML</strong>Â Â Â  -&gt; What is xml? and what&#8217;s the use of it?</li>
<li><strong>AJAX</strong> -&gt; What is ajax? if you use 3rd party tool at least know the basic functions.</li>
<li><strong>Frameworks</strong> &#8211; &gt; Design patterns used? MVC? Explain cakephp, zend etc</li>
<li><strong>CMS</strong>-&gt; At least the knowledge of integrating a template. Joomla, Drupal, Magento</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/back-to-the-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sessions and cookies</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/sessions-and-cookies/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/sessions-and-cookies/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 10:51:35 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[Regular level]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php security]]></category>
		<category><![CDATA[sessions]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/?p=338</guid>
		<description><![CDATA[Face to face technical interviews, questions related to sessions and cookies will pop up regularly. Since most of the developers are familiar with these sort of basic php questions they tend to ask more tricky questions, but if you have the correct idea then it is easy to answer any of those tricky questions. Let&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Face to face technical interviews, questions related to sessions and cookies will pop up regularly. Since most of the developers are familiar with these sort of basic php questions they tend to ask more tricky questions, but if you have the correct idea then it is easy to answer any of those tricky questions. Let&#8217;s have a look on potential questions,</p>
<dl>
<dt>Where is the sessions are stored?</dt>
<dd>Sessions are stored in server side and it is accessed by a unique id which is known as the session-id where each user/visitor is assigned when they access your website.</dd>
<dt>How the session-id is propagated within your website?</dt>
<dd>Basically, there are 2 methods either <strong>store it in a cookie</strong> or <strong>propagated in the URL</strong>. </dd>
</dl>
<p>Session security questions will not be asked in an entry level interviews but, if an advanced level candidate who has experience in developing robust and secured application must know about the vulnerabilities.</p>
<p>Leaking out an existing session-id to a third party is very risky if the session is filled with more important information.<br />
Main two methods of vulnerabilities are,<br />
- When the session-id is carrying in URLs<br />
If an external link from your site, a URL with the id might be stored in the external site&#8217;s referrer log.</p>
<p>- Active attacker might listen to network traffic<br />
While the session-id flows over the network and if it is not encrypted an active listener might grab it. The best solution is to implement SSL and make it a must for all the users.<br />
<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/sessions-and-cookies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oral php interview questions</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/oral-php-interview-questions/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/oral-php-interview-questions/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 10:39:12 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[interviews]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[sessions]]></category>

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

Here is a list of php question areas that might be asked in an add-hoc oral technical interview.
First of all they will focus on some more basic questions,
- Difference between GET and POST
- Echo and print
- Language constructors and so on&#8230;
Then most likely they would focus on,
- The behaviors of sessions and cookies
- Ways of [...]]]></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>
<p>Here is a list of php question areas that might be asked in an add-hoc oral technical interview.</p>
<p>First of all they will focus on some more basic questions,<br />
- Difference between GET and POST<br />
- Echo and print<br />
- Language constructors and so on&#8230;</p>
<p>Then most likely they would focus on,<br />
- The behaviors of sessions and cookies<br />
- Ways of a session ID can be passed<br />
- Db connection strings and how can it be centralized and stuff like that.<br />
- Difference between normal connection and a persistent connection etc..</p>
<p>Then obviously the interviewer will have to asses on your knowledge in Object Oriented Programming techniques,<br />
- Simply what is a class or object?<br />
- Some definitions on OOP techniques like, Encapsulation, overloading, inheritance.</p>
<p>Also design pattern questions will be asked here.<br />
- Which OOP pattern implements a class that must be instantiated only once in a life span of a script?<br />
- Some more questions on design patterns mostly real world scenarios.<br />
- How design patterns can be used as a mix of more than one pattern?<br />
- Some more discussions related to MVC, Abstract factory, and singleton.</p>
<p>Last but not least they will focus on your knowledge about the security issues, best practices, probably about register global issues and so on. Then the interviewers will focus on more into your CV and about the Frameworks and CMS&#8217;s you have been exposed to.</p>
<p>We will be discussing all of above points one by one in later posts stay tuned.</p>
<p>Cheers !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/oral-php-interview-questions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php security interview questions</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/php-security-interview-questions/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/php-security-interview-questions/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 11:11:55 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Advanced level]]></category>
		<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[php security]]></category>
		<category><![CDATA[register global]]></category>

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

Consider the following code snippet. Is this code acceptable from a security standpoint?
Assume that the $action and $data variables are designed to be accepted from the user and
register_globals is enabled.

&#60;?php
if(isUserAdmin()) {
 $isAdmin = true;
}
$data = validate_and_return_input($data);
switch($action){
 case 'add':
 addSomething($data);
 break;
case 'delete':
 if($isAdmin) {
 deleteSomething($data);
 }
break;
case 'edit':
 if($isAdmin) {
 editSomething($data);
 }
break;
default:
print â€œBad Action.â€;
}
?&#62;

A. Yes, it is [...]]]></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>
<p>Consider the following code snippet. Is this code acceptable from a security standpoint?<br />
Assume that the $action and $data variables are designed to be accepted from the user and<br />
register_globals is enabled.</p>
<pre class="brush: php;">
&lt;?php
if(isUserAdmin()) {
 $isAdmin = true;
}
$data = validate_and_return_input($data);
switch($action){
 case 'add':
 addSomething($data);
 break;
case 'delete':
 if($isAdmin) {
 deleteSomething($data);
 }
break;
case 'edit':
 if($isAdmin) {
 editSomething($data);
 }
break;
default:
print â€œBad Action.â€;
}
?&gt;
</pre>
<p>A. Yes, it is secure. It checks for $isAdmin to be True before executing protected operations<br />
B. No, it is not secure because it doesnâ€™t make sure $action is valid input<br />
<strong>C. No, it is not secure because $isAdmin can be hijacked by exploiting register_globals</strong><br />
D. Yes, it is secure because it validates the user-data $data<br />
E. Both A and B</p>
<p>The correct answer is C. This code is, by any means, not secure! In fact, it is the classic security exploit of PHP scripts using the register_globals configuration directive. The problem lies in the $isAdmin variable: although this is clearly a Boolean value, it is only set in the event that the user is an Admin and not set at all if the user is not. Because register_globals is enabled, by simply appending that variable to the end of the URL as a GET parameter, a malicious user could easily impersonate an administrator:</p>
<p>http://www.example.com/action.php?action=delete&#038;data=foo&#038;isAdmin=1</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/php-security-interview-questions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Blue print of an object</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/blue-print-of-an-object-php/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/blue-print-of-an-object-php/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 12:02:36 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[Regular level]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/?p=324</guid>
		<description><![CDATA[What is the construct used to define the blueprint of an object called?
A class is a blueprint of an object, which is an instance of a class. 




]]></description>
			<content:encoded><![CDATA[<p>What is the construct used to define the blueprint of an object called?</p>
<p>A class is a blueprint of an object, which is an instance of a class. </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>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/blue-print-of-an-object-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Strings and regular expressions</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/strings-and-regular-expressions-php-interview-questions/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/strings-and-regular-expressions-php-interview-questions/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 12:08:03 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[Regular level]]></category>
		<category><![CDATA[Interview]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[Strings]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/?p=284</guid>
		<description><![CDATA[What will be the answer of the following code snippet?

echo 'Testing ' . 1 + 2 . '45';

Simply you will give the answer as : Testing 345
But the answer is  : 245
That is because you can not sum a number with a string. The first part, before the plus mark is a string though [...]]]></description>
			<content:encoded><![CDATA[<p>What will be the answer of the following code snippet?</p>
<pre class="brush: php;">
echo 'Testing ' . 1 + 2 . '45';
</pre>
<p>Simply you will give the answer as : Testing 345</p>
<p>But the answer is  : 245</p>
<p>That is because you can not sum a number with a string. The first part, before the plus mark is a string though there is 1 there.<br />
So engine will simply get it as 0 and the latter part as 245. so answer will be 245.</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/strings-and-regular-expressions-php-interview-questions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>String Concatenation and regular expressions</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/string-concatenation-and-regular-expressions/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/string-concatenation-and-regular-expressions/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 12:08:24 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Advanced level]]></category>
		<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[Regular Expressions]]></category>
		<category><![CDATA[Strings]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/?p=273</guid>
		<description><![CDATA[Following question were asked in a technical php interview question paper
Which of the following will not combine strings $s1 and $s2 into a single string?

$s1 = 'a';
$s2 = 'b';
A. $s1 + $s2
B. "{$s1}{$s2}"
C. $s1.$s2
D. implode('', array($s1,$s2))
E. All of the above combine the strings
You can not concatenate 2 string using &#8220;+&#8221;. The answer will be &#8220;0&#8243;; [...]]]></description>
			<content:encoded><![CDATA[<p>Following question were asked in a technical php interview question paper</p>
<p>Which of the following <strong>will not</strong> combine strings $s1 and $s2 into a single string?</p>
<blockquote><p><code><br />
$s1 = 'a';<br />
$s2 = 'b';<br />
A. $s1 + $s2<br />
B. "{$s1}{$s2}"<br />
C. $s1.$s2<br />
D. implode('', array($s1,$s2))<br />
E. All of the above combine the strings</code></p></blockquote>
<p>You can not concatenate 2 string using &#8220;+&#8221;. The answer will be &#8220;0&#8243;; so here the answer is 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/string-concatenation-and-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Strings and Regular Expressions</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/strings-and-regular-expressions/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/strings-and-regular-expressions/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 12:03:52 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Advanced level]]></category>
		<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[Strings]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/?p=265</guid>
		<description><![CDATA[Consider the following script. What line of code should be inserted in the marked location in
order to display the string php when this script is executed?

$alpha = 'abcdefghijklmnopqrstuvwxyz';
$letters = array(15, 7, 15);
foreach($letters as $val) {
/* What should be here */
}
A. echo chr($val);
B. echo asc($val);
C. echo substr($alpha, $val, 2);
D. echo $alpha{$val};
E. echo $alpha{$val+1}

An array can be [...]]]></description>
			<content:encoded><![CDATA[<p>Consider the following script. What line of code should be inserted in the marked location in<br />
order to display the string php when this script is executed?</p>
<pre class="brush: php;">
$alpha = 'abcdefghijklmnopqrstuvwxyz';
$letters = array(15, 7, 15);
foreach($letters as $val) {
/* What should be here */
}</pre>
<p>A. echo chr($val);<br />
B. echo asc($val);<br />
C. echo substr($alpha, $val, 2);<br />
<strong>D. echo $alpha{$val};</strong><br />
E. echo $alpha{$val+1}<br />
<br />
An array can be accessed like this as well. $alpha{$val}<br />
<br />
<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/strings-and-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>heredoc syntax</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/heredoc-syntax/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/heredoc-syntax/#comments</comments>
		<pubDate>Tue, 18 May 2010 00:28:50 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Advanced level]]></category>
		<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[Strings]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/?p=256</guid>
		<description><![CDATA[&#8220;heredoc&#8221; syntax can be used to declare complex strings,
What will out put the following code snippet?
&#60;?php
$who = &#34;questions&#34;;
echo &#60;&#60;&#60;TEXT
So I said, &#34;php interview $who&#34;
TEXT;
?&#62;
Answer &#8211; So I said, &#8220;php interview questions&#8221;
In general, the functionality of this heredoc syntax is similar to double quotes. 




]]></description>
			<content:encoded><![CDATA[<p>&#8220;heredoc&#8221; syntax can be used to declare complex strings,</p>
<p>What will out put the following code snippet?</p>
<pre class="brush: php;">&lt;?php
$who = &quot;questions&quot;;
echo &lt;&lt;&lt;TEXT
So I said, &quot;php interview $who&quot;
TEXT;
?&gt;</pre>
<p>Answer &#8211; So I said, &#8220;php interview questions&#8221;</p>
<p>In general, the functionality of this heredoc syntax is similar to double quotes. </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>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/heredoc-syntax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>variable interpolation</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/variable-interpolation/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/variable-interpolation/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 13:35:28 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[Regular level]]></category>
		<category><![CDATA[Strings]]></category>

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

Using variable interpolation how we can print the following String?
&#8220;I am visiting the php interview questions website&#8221;.
The word &#8220;question&#8221; is inside a variable,
$a = &#8216;question&#8217;;
Answer is just,
echo &#8220;I am visiting the php interview {$a}s website&#8221;;




]]></description>
			<content:encoded><![CDATA[<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><br />
Using variable interpolation how we can print the following String?</p>
<p><strong>&#8220;I am visiting the php interview questions website&#8221;</strong>.<br />
The word &#8220;question&#8221; is inside a variable,<br />
$a = &#8216;question&#8217;;</p>
<p>Answer is just,<br />
echo &#8220;I am visiting the php interview {$a}s website&#8221;;</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/variable-interpolation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

