Blog Details

Technical Questions In Php :-


                                
                                    <h2><strong>1) What is PHP?</strong></h2>
<ul>
	<li>PHP stands for PHP : Hypertext Preprocessor.</li>
	<li>PHP is a server side scripting language, like ASP</li>
	<li>PHP scripts are executed on the server.</li>
	<li>PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)</li>
	<li>PHP is an open source software (OSS).</li>
	<li>PHP is free to download and use</li>
</ul>
&nbsp;
<h2>2) What is Difference Between $a $$a in php?</h2>
<ul>
	<li>This is a <strong>variable variable</strong>. They are evil.</li>
	<li><strong><code>$a</code></strong> represents a <strong>variable</strong></li>
	<li><strong><code>$$a</code></strong> represents a <strong>variable with the content</strong> of <code>$a</code></li>
</ul>
&nbsp;
<h3>Example 1:</h3>
<pre><code>$test = "hello world";
$a = "test";
echo $$a;

<strong>output will be <code>hello world

</code></strong></code></pre>
<h3>Example 2:</h3>
Assuming <code>$a = "foo";</code>, <code>$$a</code> will be same as <code>$foo</code>

&nbsp;
<h2><strong>3) what is return mysql_query($query) in php ?
</strong></h2>
<ul>
	<li>For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, <strong>mysql_query()</strong> returns a resource on success, or <strong><code>FALSE</code></strong> on error.</li>
	<li>For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, <strong>mysql_query()</strong> returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on error.</li>
	<li>The <strong>returned result</strong> resource should be passed to :</li>
</ul>
&nbsp;

<span style="font-size: 15px;"><b> </b></span>
<h3>                1. mysql_fetch_array()</h3>
<ol>
<ul>
<ul>
	<li>The mysql_fetch_array() function returns a row from a recordset as an <strong>associative array</strong> and/or a <strong>numeric array.</strong></li>
</ul>
	<li></li>
</ul>
</ol>
<h3>                2. mysql_num_rows()</h3>
<ol>
<ul>
<ul>
	<li>Retrieves the <strong>number of rows</strong> from a result set. This command is only valid for statements like SELECT or SHOW that return an actual result set.</li>
</ul>
	<li></li>
</ul>
</ol>
<h3>                3. mysql_affected_rows()</h3>
<ol>
<ul>
<ul>
	<li>to find out how many rows were affected by a <strong>DELETE, INSERT, REPLACE,</strong> or <strong>UPDATE</strong> statement.</li>
</ul>
	<li></li>
</ul>
</ol>
<h3>                4. mysql_fetch_row()</h3>
<ul>
<ul>
<ul>
	<li>The mysql_fetch_row() function returns a row from a recordset as a <strong>numeric array.</strong></li>
</ul>
	<li></li>
</ul>
</ul>
<h3><strong>                5. mysql_fetch_assoc()</strong></h3>
<ul>
<ul>
<ul>
	<li>The mysql_fetch_assoc() function returns a row from a recordset as an <strong>associative array.</strong></li>
</ul>
	<li></li>
</ul>
</ul>
<span style="color: #ff0000;"><span style="text-decoration: line-through;"> </span></span>
<h6><strong style="font-size: 1.5em;">
4) What is the difference between static and Dynamic Web Sites?</strong></h6>
&nbsp;
<h3><strong>Static</strong> :</h3>
<ul>
	<li>In programing language Static is non zero content. We can not change after run the script.</li>
	<li>Can not change anything in the site/PreDefined/Constant.</li>
</ul>
&nbsp;
<h3><strong>Dynamic</strong> :</h3>
<ul>
	<li>Run time change the content of script...!!</li>
	<li>Can change in run time.</li>
</ul>
&nbsp;
<h2><strong>5) How Many Types of the array in PHP ?</strong></h2>
<ul>
	<li>
<h3><b>Indexed arrays</b></h3>
- Arrays with <strong>numeric index</strong></li>
</ul>
<h3><strong>Example:</strong></h3>
&lt;?php
$cars=array("Volvo","BMW","Toyota");
$arrlength=count($cars);

for($x=0;$x&lt;$arrlength;$x++)
{
echo $cars[$x];
echo "&lt;br&gt;";
}
?&gt;
<ul>
	<li>
<h3><b>Associative arrays</b></h3>
- Arrays with<strong> named keys</strong></li>
</ul>
<h3><strong>Example:</strong></h3>
&lt;?php

$age=array("Peter"=&gt;"35","Ben"=&gt;"37","Joe"=&gt;"43");
echo "Peter is " . $age['Peter'] . " years old.";
?&gt;
<ul>
	<li>
<h3><b>Multidimensional arrays</b></h3>
- Arrays containing one or more arrays</li>
</ul>
<h3><strong>Example:</strong></h3>
&lt;?php

$cars = array
(
array("Volvo",22,18),
array("BMW",15,13),
array("Saab",5,2),
array("Land Rover",17,15)
);
echo $cars[0][0].": In stock: ".$cars[0][1].", sold: ".$cars[0][2].".&lt;br&gt;";
echo $cars[1][0].": In stock: ".$cars[1][1].", sold: ".$cars[1][2].".&lt;br&gt;";
echo $cars[2][0].": In stock: ".$cars[2][1].", sold: ".$cars[2][2].".&lt;br&gt;";
echo $cars[3][0].": In stock: ".$cars[3][1].", sold: ".$cars[3][2].".&lt;br&gt;";
?&gt;

&nbsp;
<h2><strong>6)</strong> What is the difference between temporary cookies and persistent cookies?<strong>
</strong></h2>
<ul>
	<li>Temporary cookies <strong>can not</strong> be used for <strong>tracking long term</strong> information.</li>
	<li>Persistent cookies <strong>can be</strong> used for <strong>tracking long term</strong> information.</li>
	<li>Temporary cookies are <strong>safer</strong> because no programs other than the <strong>browser can access them.</strong></li>
	<li>Persistent cookies are <strong>less secure</strong> because users can <strong>open cookie files</strong> see the cookie values..</li>
</ul>
&nbsp;
<h2>7)  What is the difference between PHP4 and PHP5?</h2>
<ul>
	<li>PHP4 cannot support oops concepts and Zend engine 1 is used.</li>
	<li>PHP5 supports oops concepts and Zend engine 2 is used. Error supporting is increased in PHP5. XML and SQLLite will is increased in PHP5.</li>
</ul>
&nbsp;
<h2><b>8) How can we know the number of days between two given dates using PHP? </b></h2>
$date1 = date('Y-m-d');
$date2 = '2006-07-01';
$days = (strtotime() - strtotime()) / (60 * 60 * 24);
echo "Number of days since '2006-07-01': $days";

&nbsp;
<h2><b>9) How can we repair a MySQL table?</b></h2>
<ul>
	<li>The <strong>syntex</strong> for repairing a <strong>mysql table</strong> is:</li>
</ul>
REPAIR TABLE tablename
REPAIR TABLE tablename QUICK
REPAIR TABLE tablename EXTENDED
<ul>
	<li>This <strong>command</strong> will <strong>repair</strong> the table specified.</li>
	<li>If QUICK is given, MySQL will do a repair of only the index tree.</li>
	<li>If EXTENDED is given, it will create index row by row.</li>
</ul>
&nbsp;
<h2><b>10) What is the difference between mysql_fetch_object and mysql_fetch_array? </b></h2>
<ul>
	<li><strong>MySQL fetch object</strong> will collect <strong>first single matching record</strong> where <strong>mysql_fetch_array</strong> will collect all matching records from the table in an array.</li>
</ul>
&nbsp;
<h2><b>11) What is the functionality of the functions STRSTR() and STRISTR()? </b></h2>
<ul>
	<li>string strstr ( string haystack, string needle ) <strong>returns part of haystack string</strong> from the <strong>first occurrence</strong> of needle to the end of haystack. This function is <strong>case-sensitive</strong>.</li>
</ul>
<ul>
	<li>stristr() is idential to strstr() except that it is <strong>case insensitive</strong>.</li>
</ul>
&nbsp;
<h2>12) What is the Difference between count() and strlen() ?</h2>
<ul>
	<li>count() is for getting the <strong>number of elements in an array</strong> <strong>or object</strong>.</li>
	<li>number</li>
	<li>strlen() is for getting the <strong>number of characters in a string</strong>.</li>
</ul>
&nbsp;
<h4></h4>
<h4></h4>
<h4></h4>
                                    


Categories

Core_PHP

Latest posts

13.05.14
Implementing CRUD Operations ¶

<ul> <li>Now comes the fun part. We would like t

13.05.14
View

<ol> <li><a href="http://www.yiiframework.com/do

13.05.14
Creating Model

<ol> <li><a href="http://www.yiiframework.com/do

Get Free Quote