PHP in HindiProgramming Language

How to build a Query String in PHP?

Program – How to build a Query String in PHP? Sometime you need to construct a link that includes name/value pair in a query string here is a example.

Solution – Build a Query String in PHP

<?php
$var = array('name'=>'hindialerts.com', 'type'=>'website', 'content'=>'php tutorials');
$query_string = http_build_query($var);
$url = 'https://www.google.com/search?q='.$query_string;
echo $url;
?>

 

Related Articles

Leave a Reply

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

Back to top button
Close