Saturday, December 9, 2017

PHP Developer interview questions


For more questions:
https://sharag.wordpress.com/2008/08/28/freshers-phpmysql-technical-interview-questions-answers/

1. Who is the father of PHP ?
Rasmus Lerdorf is known as the father of PHP.


2. What is the difference between $name and $$name?

$name is variable where as $$name is reference variable like $name=sonia and $$name=singh so $sonia value is singh.




3. What are the method available in form submitting?

GET and POST



4.How can we get the browser properties using PHP?


<?php

echo $_SERVER[‘HTTP_USER_AGENT’].”\n\n”;
$browser=get_browser(null,true);
print_r($browser);
?>




5. What Is a Session?

A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests. Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor.



6. How can we register the variables into a session?

<?php
session_register($ur_session_var);
?>



7. How many ways we can pass the variable through the navigation between the pages?

Register the variable into the session
Pass the variable as a cookie
Pass the variable as part of the URL





8. How can we know the total number of elements of Array?

sizeof($array_var)
count($array_var)





9. How can we create a database using php?

mysql_create_db();




10. What is the functionality of the function strstr and stristr?

strstr() returns part of a given string from the first occurrence of a given substring to the end of the string.
For example:strstr("user@example.com","@") will return "@example.com".
stristr() is idential to strstr() except that it is case insensitive.





11. What are encryption functions in PHP?


CRYPT(), MD5()




12. How to store the uploaded file to the final location?

move_uploaded_file( string filename, string destination)




13. Explain mysql_error().

The mysql_error() message will tell us what was wrong with our query, similar to the message we would receive at the MySQL console.




14. What is Constructors and Destructors?


CONSTRUCTOR : PHP allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.


DESTRUCTORS : PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as all references to a particular object are removed or when the object is explicitly destroyed or in any order in shutdown sequence.




15. Explain the visibility of the property or method.

The visibility of a property or method must be defined by prefixing the declaration with the keywords public, protected or private.
Class members declared public can be accessed everywhere.
Members declared protected can be accessed only within the class itself and by inherited and parent classes.
Members declared as private may only be accessed by the class that defines the member.




16. What are the differences between $_GET and $_POST methods.

There are some defference between GET and POST method
1. GET Method have some limit like only 2Kb data able to send for request
But in POST method unlimited data can we send
2. when we use GET method requested data show in url but
Not in POST method so POST method is good for send sensetive request



17. What are the differences between require and include?

Both include and require used to include a file but when included file not found
Include send Warning where as Require send Fatal Error



18. What is use of header() function in php ?

The header() function sends a raw HTTP header to a client.We can use herder()
function for redirection of pages. It is important to notice that header() must
be called before any actual output is seen.

19. List out the predefined classes in PHP?

Directory
stdClass
__PHP_Incomplete_Class
exception
php_user_filter



20. What type of inheritance that PHP supports?

In PHP an extended class is always dependent on a single base class,that is, multiple inheritance is not supported. Classes are extended using the keyword 'extends'.



21. How can we encrypt the username and password using php?

You can encrypt a password with the following Mysql>SET PASSWORD=PASSWORD("Password");
We can encode data using base64_encode($string) and can decode using base64_decode($string);


22. What is the difference between explode and split?

Split function splits string into array by regular expression. Explode splits a string into array by string.
For Example:explode(" and", "India and Pakistan and Srilanka");
split(" :", "India : Pakistan : Srilanka");
Both of these functions will return an array that contains India, Pakistan, and Srilanka.


23. How do you define a constant?

Constants in PHP are defined using define() directive, like define("MYCONSTANT", 100);



24. How do you pass a variable by value in PHP?


Just like in C++, put an ampersand in front of it, like $a = &$b;



25. What does a special set of tags <?= and ?> do in PHP?

The output is displayed directly to the browser.



26. How do you call a constructor for a parent class?

parent::constructor($value)



27. What’s the special meaning of __sleep and __wakeup?

__sleep returns the array of all the variables than need to be saved, while __wakeup retrieves them.



28. What is the difference between PHP and JavaScript?


javascript is a client side scripting language, so javascript can make popups and other things happens on someone’s PC. While PHP is server side scripting language so it does every stuff with the server.



29. What is the difference between the functions unlink and unset?

unlink() deletes the given file from the file system.
unset() makes a variable undefined.



30. How many ways can we get the value of current session id?

session_id() returns the session id for the current session.



31. What are default session time and path?


default session time in PHP is 1440 seconds or 24 minutes
Default session save path id temporary folder /tmp



32. for image work which library?

we will need to compile PHP with the GD library of image functions for this to work. GD and PHP may also require other libraries, depending on which image formats you want to work with.



33. How can we get second of the current time using date function?

<?php
$second = date(“s”);
?>



34. What are the Formatting and Printing Strings available in PHP?


printf()- Displays a formatted string
sprintf()-Saves a formatted string in a variable
fprintf() -Prints a formatted string to a file
number_format()-Formats numbers as strings



35. How can we find the number of rows in a result set using PHP?


$result = mysql_query($sql, $db_link);
$num_rows = mysql_num_rows($result);
echo "$num_rows rows found";

0 comments:

Post a Comment

Labels

.htaccess (5) 2step verification in php (1) 404 Page (1) Address Autocomplete (1) Admin (1) Ajax (3) alias key generation (1) All Browsers Testing (1) Android (19) Android 5.0 (2) Android Life Cycle (1) Android webview media capture (1) angular js (7) Angular Js ebook (1) AngularJS (23) Apache and mysql start up automatically once system boot (1) array_combine() (1) array_merge() (1) array_search() (1) async css and js (1) auto generate url slug in codeginiter (1) Auto reload (1) Autocomplete (1) automation code for php and mysql (1) AWS EC2 Hosting (5) AWS EC2 Hosting Connect with notepad++ (1) AWS ECS Hosting (1) base_url() (1) Basic php example on this keyword use (1) Best Practices to write jquery (1) Bootstrap (2) Bootstrap form tag problem (1) Bootstrap Modal (1) Bootstrap Modals (1) Breadcrumb (1) Broad band usage meter (1) Can't connect to MySQL server on (1) Cannot retrieve metalink for repository (1) Career Guidance (1) Carousel (1) Categories of websites (1) Cent OS (2) CI (1) Ci Errors (1) ckeditor (3) Clear Browser Cache Trick (1) Client IP Address (1) Code completion for codeigniter (1) Codehint for CodeIgniter (1) CodeIgniter (53) Codeigniter Controllers (1) Codeigniter email (1) Codeigniter file upload (2) Codeigniter send grid integration (1) CodeIgniter with Dreamweaver (1) color replace function in jquery (1) colorReplace function (1) configuration files locations (1) Controllers in controllers angular js (1) Cookies (1) core php file upload (1) count down timer in seconds in jquery (1) Countries Table in mysql (1) Create User in mysql Db (1) CryptoJS (1) CSS (3) CSS tricks (2) curl parallel calls (1) Currency API (1) Customize date format in php (1) Data dictionary (1) data of birth validation and generation codeigniter (1) Database backup in php (1) date (1) Date Difference (2) date difference in jquery (1) Date format in php (1) Date functions (1) datepicker date format jquery (1) Datetime Picker (1) datewise mysql backup (1) DBFunctions (1) Default Image in html (1) Desktop tricks (1) Detect Android Mobile (1) Detect Iphone using javascript (1) Disadvantages of Joomla (1) Disadvantages of Wordpress (1) Distance Calculation (1) document printing (1) Document submit (1) dreamweaver (1) Drupal CMS (2) Drupal Components (1) Drupal Update (1) Dynamic jQuery (21) Dynamic websites building (1) echo (1) editor for html interface (1) Email (2) Email extract in php (1) email php configuration (1) empty() and is_null() difference (1) error handling in php (1) event.PreventDefault() (1) execution time in javascript (1) extract numbers php (1) Facebook Link Posting (1) Facebook Login Error Javascript (1) Facebook Page Likes (1) Fancybox (1) Features of Joomla (1) Features of Wordpress (1) file upload (1) File upload in jquery (1) File upload through URL with php script (1) file_get_contents (1) Files listing from folders in php (1) FileUpload (2) fileupload in jquery with preview (1) filezilla (1) Filter to top (1) Find the Framework of a website (1) Firewall Configuration in Centos (1) FOR php developers (2) Form_validation form with codeigniter (1) FTP (1) Full calendar (1) Geo API (4) Geo Code (2) Geo complete (1) Geo Location (1) GeoLocation (4) get ipaddress (1) gmail contacts api (1) Google Chrome Install (1) Google Map (1) Google Maps (8) Grant all privileges in mysql db (1) Grocery Crud (5) Guess CMS (1) hashtag (1) History Clear (1) HMVC (1) Host is not allowed to connect to MySQL Server (1) how to include header and footer html in html (1) How to prevent sql injection in php (1) how to zip file in linux (1) HTML (4) HTML CSS JS compression (1) HTML Typography (1) HTML5 (4) httpd.conf Configurations (1) Huge IT Silder (1) Hybrid App (1) Hyperlinks (1) image resize in codeigniter (1) Image with preview and remove html (1) Include() and include_once Difference (2) India States (1) Interfaces in PHP (1) Internal server error solution (1) Invoice Templates (1) ionic (13) ionic ios (1) iOS (3) iTunes (1) Javascript (45) javascript countdown timer (1) javascript email validation (1) Javascript Object properties view (1) Javascript UNIX time stamp converter (1) Jquery (40) jquery datepicker (2) jquery detect idle state (1) jquery list sort (1) Jquery OWL Carousel (1) Jquery UI (1) jquery username validation (1) jquery validation (1) JS (1) JSON (3) Laravel (4) Laravel Tutorials (2) Latest Android Version (1) Linux commands (5) LINUX Ftp Configuration (1) Linux Server IP Address (1) List Sortable in Jquery UI (1) Lollipop (1) Magento (1) mail in php (1) main controller and child controller and another child controller (1) maximum execution time in php code (1) Media Capture in HTML5 (1) method overloading in php (1) method overriding in php (1) mod_rewrite (1) Mouse Deselection Javascript (1) Multidimensinal Array sort (1) multiple comparisons in php (1) Multiple file upload in Angular JS (1) Multiple file upload in jquery (1) multiple file upload in php (1) multiselect (1) Mysql (20) mysql and apache start up automatically once system boot (1) mysql connect (1) mysql connect in windows os (1) mysql database backup (1) mysql datatypes (1) Mysql DB (1) mysql Db connection program (1) Mysql Errors (1) mysql functions (1) MySQL HostName (1) mysql query tricks (1) MySQL server at 'reading initial communication packet' (1) mysql_real_escape_string() (1) mysql_secure_installation (1) mysql.sock (2) Error (1) mysqli (2) Native App (1) Netbeans for linux (1) Network usage monitor (1) ng-bind (1) ng-click (1) Node js (1) Notepad++ (1) onchange display images (1) Online UNIX Timestamp to human readble format converter (1) OOPS in php (1) Pagination in Codeigniter (1) Pagination in php (1) Password encryption and decryption in php (1) Paypal (1) PayU Form (1) PDF (1) PDO (2) Pendrive Data Recovery (1) php (62) PHP 5.4.0 (2) php abstract class example (1) PHP ajax file upload (2) PHP ajax request detection (1) PHP Basic Login and logout (1) PHP Codeigniter database backup code (1) PHP Contact us email form code (1) PHP corn jobs (1) php database backup script (1) php email validation (1) PHP Environment Setup (1) PHP Errors (1) PHP Extension and Application Repository) (1) php file upload (1) PHP File Uploading (1) PHP fileupload helper in codeigniter (1) PHP interview questions (4) PHP lamda functions examples (1) PHP Login (1) PHP pdo (1) PHP PDO script to insert data inside mysql db (1) PHP Random Password generation Script (2) php script execution limit (1) php script to display months (1) php script to print years as dropdown (1) PHP Storm (2) PHP Storm license key (1) PHP strong encryption and decryption (1) php timeslot generator (1) php-mysql Modules (1) phpmyadmin (2) phpMyAdmin install (1) Pin-code finder (1) Pincode (1) Play youtube video in angular JS (1) Popup (2) POPUP in javascript (1) POST and GET Difference (1) POST DATA IN PHP (1) Postfix sendmail (1) preview of selected file (1) Print content with jquery (1) print() (1) Push Notifications (1) query string based pagination in codeigniter (1) Random key (1) ratings (1) regular expressions (1) remote validation (1) remove query string (1) Remove Sale Tag or Logo of woocommerce (1) Repository (1) require_once() (1) require() (1) Resize Image Dynamically (1) result_array() (1) rpmdb open fail (1) Salaries (1) SCP Command syntax (1) select images display in webbrowser (1) Selected values in javascript (1) Send free sms (1) Send Grid (1) Send Grid Email integration (1) SEO PHP (1) Session Management in PHP (1) show active class in the url automatically php (1) Show alternate image (1) simple ajax php script (1) Simple Login in PHP (1) Simple registraion (1) single file upload (1) site2sms script (1) Slideshow (1) SMTP Configuration (2) SOFTWARE TECHNOLOGY TIPS (1) Sort list items by Mouse in jquery (1) sprintf in php (1) SQL Injection in php (1) States Countries API (1) static variable in javascript (1) store date in php (1) stripslashes() (1) strtotime (1) sum of array values (1) sumo select (1) system error: 113 (1) Text to ASCII Generator (1) this keyword (1) Time ago function in javascript (1) Time ago Plugin (1) Time in PHP (1) time picker in grocery crud admin (1) Timeslot Generation in PHP (1) Tooltips using css (1) trigger in mysql (1) ubuntu (1) UNIX timestamp to HUMan readable converter (1) use full tutorials (1) user ur domain inseted of localhost (1) validation in javascript (1) Version Controls for PHP (1) Webmin (1) What CMS (1) Why Drupal CMS (1) Windows 10 (1) Windows Commands (1) Wordpress (2) Xampp (2) Xampp Localhost (1) Xampp Security (1) Yii Framework configuration (1) Yii framework installation (1) ZipArchive (1) ZipArchive php aws (1)
 
TOP