PHP Interview Questions (part-1)
- What are the differences between GET and POST methods in form submitting, give the case where we can use get and we can use post methods?
- Who is the father of php and explain the changes in php versions?
- How can we submit from without a submit button?
- How many ways we can retrieve the date in result set of mysql Using php?
- What is the difference between mysql_fetch_object and mysql_fetch_array?
- What is the difference between $message and $$message?
- What are the differences between require and include, include_once?
- What are the different tables present in mysql?
- How can I execute a php script using command line?
- What is meant by nl2br()?
- What are the current versions of apache, php, and mysql?
- What are the reasons for selecting lamp (Linux, apache, mysql, php) instead of combination of other software programs, servers and operating systems?
- How can we encrypt and decrypt a data present in a mysql table using mysql?
- How can we encrypt the username and password using php?
- What are the different types of errors in php?
- E_ERROR: A fatal error that causes script termination
- E_WARNING: Run-time warning that does not cause script termination
- E_PARSE: Compile time parse error.
- E_NOTICE: Run time notice caused due to error in code
- E_CORE_ERROR: Fatal errors that occur during PHP's initial startup (installation)
- E_CORE_WARNING: Warnings that occur during PHP's initial startup
- E_COMPILE_ERROR: Fatal compile-time errors indication problem with script.
- E_USER_ERROR: User-generated error message.
- E_USER_WARNING: User-generated warning message.
- E_USER_NOTICE: User-generated notice message.
- .E_STRICT: Run-time notices.
- E_RECOVERABLE_ERROR: Catchable fatal error indicating a dangerous error
- E_ALL: Catches all errors and warnings
- What is the functionality of the function htmlentities?
- What is meant by urlencode and urldocode?
- What is the difference between the functions unlink and unset?
- How can we register the variables into a session?
- How can we get the properties (size, type, width, height) of an image using php image functions?
- What is the maximum size of a file that can be uploaded using php and how can we change this?
- How can we increase the execution time of a php script?
- How can we take a backup of a mysql table and how can we restore it.?
- How many ways can we get the value of current session id?
- How can we destroy the session, how can we unset the variable of a session?
On the server side, the main difference between GET and POST is where the submitted is stored. The $_GET array stores data submitted by the GET method. The $_POST array stores data submitted by the POST method.
On the browser side, the difference is that data submitted by the GET method will be displayed in the browser's address field. Data submitted by the POST method will not be displayed anywhere on the browser.
GET method is mostly used for submitting a small amount and less sensitive data. POST method is mostly used for submitting a large amount or sensitive data.
Click Here to read more about GET & POST in PHP
Rasmus Lerdorf
For version changes go to http://php.net/ Marco Tabini is the founder and publisher of php|architect.
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.
As individual objects so single record or as a set or arrays.
MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array.
They are both variables. But $message is a variable with a fixed name. $$message is a variable who's name is stored in $message. For example, if $message contains "var", $$message is the same as $var.
File will not be included more than once. If we want to include a file once only and further calling of the file will be ignored then we have to use the PHP function include_once().
This will prevent problems with function redefinitions, variable value reassignments, etc.
Total 5 types of tables we can create
1. MyISAM
2. Heap
3. Merge
4. InnoDB
5. ISAM
6. BDB
MyISAM is the default storage engine as of MySQL 3.23.
Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, "php myScript.php", assuming "php" is the command to invoke the CLI program.
Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.
Nl2br Inserts HTML line breaks before all newlines in a string string nl2br (string); For example: echo nl2br("god bless
you") will output "god bless
you" to your browser.
PHP: php 5.3
MySQL: MySQL 5.5
Apache: Apache 2.2
All of those are open source resource. Security of linux is very very more than windows. Apache is a better server that IIS both in functionality and security. Mysql is world most popular open source database. PHP is more faster that asp or any other scripting language.
AES_ENCRYPT () and AES_DECRYPT ()
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);
Answer: htmlentities Convert all applicable characters to HTML entities
This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.
Urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits. For example: urlencode("10.00%") will return "10%2E00%25?. URL encoded strings are safe to be used as part of URLs.
urldecode() returns the URL decoded version of the given string.
Unlink() deletes the given file from the file system.
unset() makes a variable undefined.
We can use the session_register ($ur_session_var) function.
To know the Image type use exif_imagetype () function
To know the Image size use getimagesize () function
To know the image width use imagesx () function
To know the image height use imagesy() function
You can change maximum size of a file set upload_max_filesize variable in php.ini file.
Set max_execution_time variable in php.ini file to your desired time in second.
Create a full backup of your database: shell> mysqldump tab=/path/to/some/diropt db_name Or: shell> mysqlhotcopy db_name /path/to/some/dir
The full backup file is just a set of SQL statements, so restoring it is very easy:
shell> mysql "."Executed";
mysql_close($link2);
session_id() function returns the session id for the current session.
session_destroy and session_unset
Comments
Post a Comment