GeekInterview.com
Series: Subject: Topic:

PHP Interview Questions

Showing Questions 1 - 20 of 98 Questions
First | Prev | | Next | Last Page
Sort by: 
 | 

How do you insert single & double qotes in MySQL db without using PHP?

Asked By: Lokesh M | Asked On: Sep 14th, 2006

Answered by: Lokesh M on: Jun 29th, 2014

We can use mysql_real_escape_string function.

Answered by: rubak on: May 22nd, 2012

By using mysql_real_escape_string()...

What is difference between MySQL_fetch_array(),MySQL_fetch_row() and MySQL_fetch_object()please insert with example

Asked By: mrbaliram | Asked On: Jun 16th, 2006

Answered by: Guru on: Jun 26th, 2014

Mysql_fetch_array(): return values as both an associative and numeric array
mysql_fetch_assoc(): return values as an associative array
mysql_fetch_row(): return values as an numeric array

Answered by: abc on: Sep 12th, 2011

Mysql_fetch_array():: fetches a result row as a associated array, numeric array

mysql_fetch_object: Fetaches a result row as object.

mysql_fetch_row::fetches a result row as array

Would you initialize your strings with single quotes or double quotes?

Asked By: illahi | Asked On: Apr 24th, 2007

Since the data inside the single-quoted string is not parsed for variable substitution, it’s always a better idea speed-wise to initialize a string with single quotes, unless you specifically need variable substitution

Answered by: Sachin on: Jun 20th, 2014

Single quotes will print the statement as a literal but double quotes prints the value for the variables also.....

Answered by: mart0 on: Feb 5th, 2014

Single quotes for performance, no matter if there are variables or not!

Set Javascript variable value

Asked By: pratibhapatel | Asked On: Dec 19th, 2009

Can you set Javascript variable value to PHP variable? Justify your answer?

Answered by: El Houba Mohammed Amine on: Jun 2nd, 2014

No impossible , php is server side , java script is executed in client browser. we can set a java script variable with some php value , not the opposite

Answered by: ionela on: Jul 29th, 2010

Php code example:$i=5; echo "var x=$i; alert(x);";

What is the difference between echo and print?

Asked By: Ashwani | Asked On: Sep 25th, 2006

If anyboyd knows, do tell me.Waiting for your prompt response.

Answered by: Deepak Dholiyan on: Dec 17th, 2013

Echo is the basic type used to print out a string. It just shows the content of the message written using it. It can have multiple parameters as well. print is a construct, it returns TRUE on successful output and FALSE there is no output.

Answered by: Ramakrishna Reddy Gouni on: Nov 29th, 2012

1. both are using to display the value.
2. echo is faster than print
3. echo displays multiple statements and variables but print only
4. print is function it returns a value.

Post and get methods

Asked By: raghuveerpm | Asked On: Jul 20th, 2009

Which will execute faster post or get? Explain

Answered by: anilmcmt on: Sep 14th, 2013

Post method send a file but get method not send a file

Answered by: Vipin Yadav on: Sep 30th, 2011

Post execute faster than get method. Get is default super global.

What is difference between require_once(), require(), include().Becouse above three function usely use to call a file in another file.

Asked By: mrbaliram | Asked On: Feb 4th, 2006

Star Read Best Answer

Editorial / Best Answer

Answered by: bicu

View all questions by bicu   View all answers by bicu

Member Since Sep-2005 | Answered On : Feb 4th, 2006

Difference between require() and require_once():  require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page).
So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don't include the file more times and you will not get the "function re-declared" error.

Difference between require() and include() is that require() produces a FATAL ERROR if the file you want to include is not found, while include() only produces a WARNING.

There is also include_once() which is the same as include(), but the difference between them is the same as the difference between require() and require_once().

Answered by: anusha on: Apr 13th, 2013

Require(): displays error and stops the execution.
whereas, include gives a warning and continues the execution.

Answered by: abc on: Sep 12th, 2011

Require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page).

Overloading concepts

Asked By: Satish gupta | Asked On: Oct 29th, 2011

Why overloading concept is not supported in PHP

Answered by: tuhin sarkar on: Apr 6th, 2013

PHP is a loosely typed language.

Answered by: Pawan Parashar on: Aug 23rd, 2012

Because variables data type can be vary, :)

How to reverse given string without using built in functions?

Asked By: Laxminarayan | Asked On: Apr 3rd, 2007

Answered by: Ravindra Singh on: Jan 29th, 2013

Code
  1. $string = RAVINDRA;
  2. $i = 0;
  3. while(isset($string[$i])){
  4.         $i++;
  5. }
  6. $i--;
  7. while(isset($string[$i])){
  8.         echo $string[$i];
  9. $i--;
  10. }
  11.  

Answered by: amitdubey2 on: Mar 29th, 2010

<?php$str_name='Sachin Tendulkar';$len=strlen($str_name);//echo $len;$i=$len;for ($i;$i>-1;$i--)   //$i>-1 because in array Ist element is start with 0th position.{echo $str_name[$i];}?>

Upload videos

Asked By: ramsari | Asked On: Nov 7th, 2008

How do you upload videos using PHP & MySQL

Answered by: vinit on: Dec 14th, 2012

For uploading videos you need not store the video in database. Just you store the video path in database. You store the videos in a separate folder like video_uploads. After uploading you can call tho...

Answered by: ajayvaineela on: Oct 21st, 2009

For uploading videos you need not store the video in database. Just you store the video path in database. You store the videos in a separate folder like video_uploads. After uploading you can call...

PHP fragment

Asked By: cat | Asked On: Nov 12th, 2011

1- write PHP fragment code to print out the data submitted by the user through HTML form using get or post method? We need to display the field name and value??

Answered by: tdka14 on: Dec 3rd, 2012

Code
  1. <?php
  2. echo '<pre>';
  3. print_r($_REQUEST);
  4. echo '</pre>';
  5.  

Answered by: cuentemelotodo on: May 8th, 2012

Code
  1. <?php
  2. echo "Post data: ";
  3. foreach ($_GET as $key => $value)
  4. {
  5. print_r($key , $value);
  6. }
  7. ?>

PHP session

Asked By: rathodvg3 | Asked On: Dec 23rd, 2008

Where does the session stored, EIther client side or server side?

Answered by: Motta Valerio on: Oct 22nd, 2012

The better way is store the sessions server side on database or, if you need high performance loosing scalability, on RAM.

Answered by: BABU on: Oct 29th, 2011

Session values are normally stored on a cookie file.Default cookie file is PHPSESID.This cookie file is stored on a client system.

Functionality of trim() function

Asked By: tallman07 | Asked On: Sep 13th, 2010

Will the trim() function strip the null bytes?

Answered by: rubak on: May 22nd, 2012

Yes

Answered by: kevinly0130 on: May 10th, 2012

By default, yes.

Store session value in cookies

Asked By: Kannan Murugesan | Asked On: Sep 16th, 2011

How to store session value in cookies ? Can we store session value in cookie ? If u can please explain how ?

Answered by: rubak on: May 22nd, 2012

By using setcookie() function...

How we know browser properties

Asked By: tarangini | Asked On: Feb 18th, 2006

Star Read Best Answer

Editorial / Best Answer

Answered by: bicu

View all questions by bicu   View all answers by bicu

Member Since Sep-2005 | Answered On : Mar 3rd, 2006

get_browser() attempts to determine the capabilities of the user's browser. This is done by looking up the browser's information in the browscap.ini file.

echo $_SERVER['HTTP_USER_AGENT'] . "<hr />\n";

$browser = get_browser
();

foreach (
$browser as $name => $value
) {
    echo
"<b>$name</b> $value <br />\n"
;
}

Answered by: naveen gautam on: Dec 24th, 2011

$_SERVER[HTTP_USER_AGENT]; by this method we can know the properties of browser.

Answered by: abc on: Sep 12th, 2011

Code
  1. echo $_SERVER['HTTP_USER_AGENT'] . "
  2. ";

How to handle drop down box change event without refreshing page?

Asked By: alpeshbsk | Asked On: Feb 7th, 2007

Answered by: Malik Adeel on: Nov 20th, 2011

You don't need AJAX to perform this action, it can be done without using AJAX by onChange() function.

Answered by: Heinz Stapff on: Nov 19th, 2011

Try
divId.innerHTML=XMLhttp.responseText
if you want the whole form the whole form has to be posted and urlencoded etc. Just echo back the parts you acctually want with the values you want?

Form submit

Asked By: arup Kr. Porel | Asked On: Nov 5th, 2008

Can you submit a form without using submit button? If yes, how?

Answered by: ram kumar on: Nov 17th, 2011

Yes we can submit without submit button using java script or one more thing is make a location header.. like....

Code
  1. Header("Location: $a");

Answered by: kedarPhp on: Sep 2nd, 2010

Add the following code at your page where you have form named as frmdemo.Click here to submit the page

What is the difference between explode and split?

Asked By: Paddy | Asked On: Nov 25th, 2006

Split - splits string into array by regular expression.Explode - split a string by stringhope this helps

Answered by: saurabh7446 on: Sep 21st, 2011

Explode convert string to array. for exmaple.

Code
  1. <?php
  2. $x="anil,mukesh,neeraj";
  3. if(is_string($x))
  4. {
  5. $y=explode(",",$x);
  6. //"," is an identifier.
  7. print-r $y;
  8. }
  9. ?>
split take multiple identifier.

Answered by: abc on: Sep 12th, 2011

Explode function is used to convert string into array & split is used to return an array

Percentage bar for processing

Asked By: ravikumar.drk | Asked On: Apr 18th, 2009

While in case of download, how will you make a percentage bar showing current status of total 100%?

Answered by: myindia on: Sep 20th, 2011

Yes, this can be done easily by using jQuery

Answered by: abc on: Sep 12th, 2011

1. Use Image for displaying Percentage Bar.

2. Change width of Image depending on Processing completed.

Store image in MySQL

Asked By: kirangona | Asked On: Jan 31st, 2010

How to store image in MySQL database via PHP?

Answered by: abc on: Sep 12th, 2011

"php $iname=$_FILES['img1']['name']; $fp=fopen($_FILES['img1']['tmp_name'],r); $con=fread($fp,filesize($_FILES['img1']['tmp_name'])); mysql_connect("localh...

Answered by: themostwanted on: Oct 13th, 2010

$iname=$_FILES['img1']['name'];    $fp=fopen($_FILES['img1']['tmp_name'],r);    $con=fread($fp,filesize($_FILES['img1']['tmp_n...

First | Prev | | Next | Last Page

 

 

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.