PHP Interview Question Set 6

Categories: PHP

Explain some of the PHP array functions?

There are many array functions in PHP:

  1. array()
  2. array_change_key_case()
  3. array_chunk()
  4. count()
  5. sort()
  6. array_reverse()
  7. array_search()
  8. array_intersect()


What is the difference between indexed and associative array?

The indexed array holds elements in an indexed form which is represented by number starting from 0 and incremented by 1. For example:


$season=array("summer","winter","spring","autumn");    

The associative array holds elements with name. For example:

$salary=array("Sonoo"=>"350000","John"=>"450000","Kartik"=>"200000");    



How to get the length of string?

The strlen() function is used to get the length of the string.



Explain some of the PHP string functions?

There are many array functions in PHP:

  1. strtolower()
  2. strtoupper()
  3. ucfirst()
  4. lcfirst()
  5. ucwords()
  6. strrev()
  7. strlen()



What are the methods to submit form in PHP?

There are two methods GET and POST.


How can you submit a form without a submit button?

You can use JavaScript submit() function to submit the form without explicitly clicking any submit button.


What are the ways to include file in PHP?

PHP allows you to include file so that page content can be reused again. There are two ways to add the file in PHP.

  1. include
  2. require


Explain setcookie() function in PHP?

PHP setcookie() function is used to set cookie with HTTP response. Once the cookie is set, you can access it by $_COOKIE superglobal variable.

Syntax:

bool setcookie ( string $name [, string $value [, int $expire = 0 [, string $path     

[, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] )    


How can you retrieve a cookie value?

echo $_COOKIE ["user"];  


What is a session?

PHP Engine creates a logical object to preserve data across subsequent HTTP requests, which is known as session.

Sessions generally store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same user.

Simply, it maintains data of an user (browser).


Top Blogs
PHP freshers Interview Questions PHP Interview Questions and Answers for Freshers & Experienced Published at:- PHP Tutorial From beginner Published at:- PHP Interview Question Set 1 Published at:- PHP Interview Question Set 3 Published at:- PHP Interview Question Set 4 Published at:- PHP Interview Question Set 6 Published at:- PHP Interview Question Set 7 Published at:- PHP Interview Question Set 8 Published at:- PHP Interview Question Set 9 Published at:- Top 5 PHP Structures Published at:- 8 Motivations To pick Php web Advancement for IT Business Published at:-
R4R.co.in Team
The content on R4R is created by expert teams.