<?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; Strings archives  &#8211; interview questions and answers</title>
	<atom:link href="http://www.phpinterviewquestions.com/tag/strings/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>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>
		<item>
		<title>strings and variable interpolation</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/strings-and-variable-interpolation/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/strings-and-variable-interpolation/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 13:00:46 +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=221</guid>
		<description><![CDATA[Basically there are 2 methods how we can define strings,
- Simple strings
- Complex strings
In a php interview, even a well experienced php programmer might forget how this works,
For an example,
a) echo &#8220;Hello $what\n&#8221;;
b) echo &#8216;Hello $what\n&#8217;;
$what = &#8220;World&#8221;;
Which will print correctly in to the browser as &#8220;Hello World&#8221; followed by a new line.
Is it a) [...]]]></description>
			<content:encoded><![CDATA[<p>Basically there are 2 methods how we can define strings,<br />
- Simple strings<br />
- Complex strings</p>
<p>In a php interview, even a well experienced php programmer might forget how this works,<br />
For an example,<br />
<strong>a) echo &#8220;Hello $what\n&#8221;;<br />
b) echo &#8216;Hello $what\n&#8217;;</strong><br />
$what = &#8220;World&#8221;;</p>
<p>Which will print correctly in to the browser as &#8220;Hello World&#8221; followed by a new line.<br />
Is it a) or b) ?<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>
<p>The answer is &#8220;a&#8221;. That is because simple string will print almost all characters literally, where complex string allows special escape sequences to insert special characters.</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-variable-interpolation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

