Pages

Thursday, November 18, 2010

PHP Interview Questions with Answers Part 5

This is the new fifith episode of PHP Interview preparation Questions with answers. Check out this collection of PHP Interview Questions with simplified Answers.
  • How can we extract string 'abc.com ' from a string http://info@abc.com using regular expression of php?
  • What is the difference between the functions unlink and unset?
  • How come the code works, but doesn’t for two-dimensional array of mine?
  • How can we register the variables into a session?
  • What is the difference between characters \023 and \x23?
  • With a heredoc syntax, do I get variable substitution inside the heredoc contents?
  • How can we submit form without a submit button?
  • How can we create a database using PHP and mysql?
  • How many ways we can retrieve the date in result set of mysql using php?
  • Can we use include ("abc.php") two times in a php page "makeit.php"?
How can we extract string 'abc.com ' from a string http://info@abc.com using regular expression of php?

We can use the preg_match() function with "/.*@(.*)$/" as 
the regular expression pattern. For example: 
preg_match("/.*@(.*)$/","http://info@abc.com",$data);
echo $data[1];
What is the difference between the functions unlink and unset?
unlink() is a function for file system handling. It will simply delete the file in context.  unset() is a function for variable management. It will make a variable undefined.
How come the code works, but doesn’t for two-dimensional array of mine?
Any time you have an array with more than one dimension, complex parsing syntax is required. print "Contents: {$arr[1][2]}" would’ve worked.
How can we register the variables into a session?
session_register($session_var);  $_SESSION['var'] = 'value';
What is the difference between characters \023 and \x23?
The first one is octal 23, the second is hex 23.
With a heredoc syntax, do I get variable substitution inside the heredoc contents?
Yes.
How can we submit form without a submit button?
We can use a simple JavaScript code linked to an event trigger of any form field. In the JavaScript code, we can call the document.form.submit() function to submit the form. For example:
How can we create a database using PHP and mysql?
We can create MySQL database with the use of mysql_create_db($databaseName) to create a database.
How many ways we can retrieve the date in result set of mysql using php?
As individual objects so single record or as a set or arrays.
Can we use include ("abc.php") two times in a php page "makeit.php"?
Yes.
For Previous Parts click below links

PHP Interview Questions with Answers Part 4

PHP Interview Questions with Answers Part 3

20 comments:

  1. Hi

    I read this post 2 times. It is very useful.

    Pls try to keep posting.

    Let me show other source that may be good for community.

    Source: Amazon interview questions

    Best regards
    Jonathan.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Thanks for sharing this valuable information to our vision
    Web design institutes in Chennai

    ReplyDelete
  4. DOT NET Training in Chennai

    I have read all the articles in your blog; was really impressed after reading it. FITA is glad
    To inform you that; we provide practical training on all the technologies with MNC exports. We
    Assure you that through our training the students will gain all the sufficient knowledge to have a voyage in IT industry.
    FITA Reviews

    ReplyDelete
  5. Hi, Thanks for sharing this valuable blog.I was really impressed by reading this blog. I did HTML5 Training in Chennai at reputed HTML5 Training Institutes in Chennai. This is reslly useful for me to make a bright future in designing field.

    ReplyDelete


  6. Thanks for sharing this information. SEO is one of the digital marketing techniques which is used to increase website traffic and organic search results. If anyone wants to get SEO Course in Chennai visit FITA Academy located at Chennai. Rated as No.1 SEO Training institute in Chennai.

    SEO Training in Chennai | SEO Training Institute in Chennai

    ReplyDelete
  7. very nice !!! i have to learning a lot of information for this sites...Sharing for wonderful information. PHP Training in chennai | PHP Training chennai | PHP course in chennai | PHP course chennai

    ReplyDelete
  8. This technical post helps me to improve my skills set, thanks for this wonder article I expect your upcoming blog, so keep sharing.
    Regards,
    cognos tm1 Training in Chennai|Python Training Institutes in Chennai|Node JS training

    ReplyDelete
  9. That was very useful question on interview, thanks author, likewise also gain knowledge on seo seo training in bangalore

    ReplyDelete
  10. This is really great news. Thank you for sharing it with us!
    oracle dba training in chennai

    ReplyDelete
  11. AWS is designed to allow application providers, ISVs, and vendors to quickly and securely host your applications. Credo Systemz provides the best AWS Training to get your certifications easily.

    aws training in chennai with placement| aws authorized training partner in chennai|aws solution architect training in chennai

    ReplyDelete
  12. your blog information's are really creative and It contains full of new innovative ideas.thank you for sharing with us.please update more data. good jobs
    Ai & Artificial Intelligence Course in Chennai
    PHP Training in Chennai
    Ethical Hacking Course in Chennai Blue Prism Training in Chennai
    UiPath Training in Chennai

    ReplyDelete