If i am sending data in query params from angular application i need to get those data in php from url. I am not familiar to php. Can anyone help me out yr?
CodePudding user response:
In your php file, check to see that you got the needed parameter. If so, handle the call as you wish. Otherwise, you can send back an error. An example: If your query param is called "someParameter", then
<?php
if (isset($_GET['someParameter'])) {
$someParameter = $_GET['someParameter'];
// Do something with it
}
else {
$httpStatusCode = 400;
$httpStatusMessage = 'someParameter is missing';
$protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
header($protocol.' '.$httpStatusCode.' '.$httpStatusMessage);
}
?>
CodePudding user response:
Pass a link in url for testing let say localhost/test/test.php?link=www.google.com
<?php
echo $_Get['link'];