how to store the url sting parameter in the $variable [duplicate] - php

This question already has answers here:
Get Last Part of URL PHP
(14 answers)
Closed 2 years ago.
Hi i am working on a wordpress website and i am little stuck into one situation,
https://jobicons.com/newsite/my-profile/
the above is the url of my web site i only want to store the my-profile parameter in the $variable , is there any way how can i do this?
Thanks in advance.

using php it is as simple as doing this:
<?php echo basename($URL);
but since you're using wordpress, this is how you should be able to get the slug name for a post
<?php
global $post;
$post_slug = $post->post_name;
?>

Related

replace particular value from url [duplicate]

This question already has answers here:
PHP, Delete parts of a URL variable [duplicate]
(3 answers)
Closed 4 years ago.
I want to replace '/50' with URL.my URL is
http://localhost/CI/admin/pcustomer/cprofile/50?customer=18267&mobile=&nearby=
I want url as
http://localhost/CI/admin/pcustomer/cprofile?customer=18267&mobile=&nearby=
From that little info in your question, this seems to be the simplest way to achieve "I want to replace '/50' with URL"
$url = str_replace('/50', '', 'http://localhost/CI/admin/pcustomer/cprofile/50?customer=18267&mobile=&nearby=');

How to get a URL query next to the "#!" prefix? [duplicate]

This question already has answers here:
Get fragment (value after hash '#') from a URL [closed]
(10 answers)
Closed 7 years ago.
I'm trying to get the URL query next the "#!" prefix, for example:
https://mega.co.nz/#!123abc
<?php
$query=$_GET["#!"]; //the example
?>
$query: 123abc.
It is possible to read the query using PHP or .htaccess file? How i can get started?
Thanks for reading and for any help! :)
Try this,
Let your URL:
https://mega.co.nz?query=123abc
Then you can get value as below :
<?php
$query=$_GET["query"]; //the example
?>

What to parameter value from returning url in php [duplicate]

This question already has answers here:
GET URL parameter in PHP
(7 answers)
Closed 7 years ago.
I have a client url[www.mysite.com/page.aspx]
when we put this url in browser then it revert the automatically
with this url
[www.mysite.com/page.aspx?|&CC=121&DD=123&AA=323|&CC=321&DD=555&AA=000]
Now we want to fetch that parameter value in php page through php or jquery.
Kindly Help and give the best suggestions.
You can simply use GET
$cc = $_GET['CC'];
$dd = $_GET['DD'];
You can access those values using $_REQUEST or $_GET

Why my $_POST is empty? [duplicate]

This question already has answers here:
What is the difference between POST and GET? [duplicate]
(7 answers)
Closed 7 years ago.
I have no time and too tired to struggle with this, so I decided to ask here: I've created the file my.php which contains only:
<?php var_dump( $_POST ); ?>
And then I open the file using browser like this:
www.domain.com/my.php?post1=hey&post2=ho&post3=letsgo
And in the browser I have array(0) { } as a response.
Question: What could I possibly done wrong??
Thanks!
In URL are GET parameters, not POST.
echo $_GET['post1']; // hey
echo $_GET['post2']; // ho
echo $_GET['post3']; // letsgo
You cant pass POST variables through URL.
u r using GET method..

Remove character from image url [duplicate]

This question already has answers here:
How to remove the querystring and get only the URL?
(16 answers)
Closed 8 years ago.
I'm new to PHP and WordPress, and i need to import image from a offshore website with the WordPress function download_URL().
My problem is, i have URL that look like that :
http://www.test/img/FMR.jpg
But i have also URL that look like that :
http://www.test/img/FMR.jpg?Qq_0y12h
And can i have remove everything that is after the .extension if there something?
you can use preg_replace, I did this little example for you.
<?php
$url = "http://www.test/img/FMR.jpg?Qq_0y12h";
echo "url = $url\n\n";
$urlFormatted = preg_replace("/\?.*$/", "", $url);
echo "urlFormatted = $urlFormatted\n";
?>

Categories