This is most basic question raised by an interviewer to PHP developer. Difference between GET and POST requests.
GET request is used to send data to server through url. Data sent using this request can be seen from URL that’s why this is not a secure method to send data. Secondly a limited amount of data can be sent using GET request. 2kb of data can be sent through GET.password or user names should not be sent using GET.max size is 7607 character while sending data to server.
POST method is also used to send from client to server but in this request data is not sent from URL. Data is sent hidden. User can not see data that is sent when form is posted. Secondly large data is sent to server using POST instead of GET. This method is secure way to send data. Files are sent to server using POST  method. POST is used to send user name,password or any other secure data.
8mb is maximum size to send data but that size can be increase from php.ini file.
Example of POST and GET methods are.
form: using GET method
<form action="php_page.php" method="GET">
<input type="text" name="name" id="name">
</form>
php code:
<?php 
$get_data = $_GET['name'];
?>
form: using POST method
<form action="php_page.php" method="POST">
<input type="text" name="name" id="name">
</form>
php code:
<?php 
$get_data = $_POST['name'];
?>
 

 

 

2 thoughts on “What is difference between GET and POST in PHP”

Leave a Reply

Your email address will not be published. Required fields are marked *