Tag Archives: POST

Use Multiple Headers in a PHP

php5




With PHP, you can send multiple HTTP headers with file_get_contents() . you can also send information such as HTTP_ACCEPT, HTTP_ACCEPT_LANGUAGE, and HTTP_CONNECTION with file_get_contents(). In this post, I have write a complete example code to set multiple headers; an Authorization header and a Content-Type header using PHP and make POST request using file_get_contents(). <?php $options = [“http” => [ “method” => “POST”, “header” => [“Authorization: token ” . $access_token, “Content-Type: application/json”], “content” => $data ]]; $context = stream_context_create($options); ?> Now […]

Php Interview Questions and Answers – Part 2

job-interview-question




1- Why doesn’t the following code print the newline properly? <?php $str = ‘Hello, there.nHow are you?nThanks for visiting techpreparation’; print $str; ?> Because inside the single quotes the n character is not interpreted as newline, just as a sequence of two characters – and n. 2- Would you initialize your strings with single quotes or double quotes? Since the data inside the single-quoted string is not parsed for variable substitution, it’s always a better idea speed-wise to initialize a […]

Form Validation with PHP

Form Validation with PHP




In this article you’ll construct and validate a simple form using HTML and PHP. The form is created using HTML and validation and processing of the form’s contents is done with PHP. The goal is to teach you some basic HTML form elements and how their data is accessible to you in your PHP scripts. The form you’ll create contains a number of inputs: text fields, radio buttons, a multiple-option select list, a checkbox, and a submit button. These inputs […]