Jump to content

Recommended Posts

Hello. I'd like to find a string within the current URL and if it returns true, run an action. This is what I have so far:

 

$url = $_SERVER["REQUEST_URI"];
$find = "text";
if (strpos($url, $find)) {
   action;
   }
   else {
     another action;
     }

 

Gosh am I even shooting in the right direction? Any thoughts?

Link to comment
https://forums.phpfreaks.com/topic/204251-find-string-within-url/
Share on other sites

Thank you very much for verifying what I was doing. I was at a bit of a loss because things weren't working out the way I wanted.

 

I found out that it was because the php I needed is inside an iFrame and it wasn't calling the URL of the parent page. Instead, it calls its own URL. When I actually search for a string within the URL for the iFrame, it works perfectly.

 

Still haven't been able to grab the URL of the parent page and based on my old friend Google, I'm not sure that it's going to be possible to get because the parent page (on the same host and part of same site) has a .html extension (over which I have no control - they want it to remain html) so I can't just pass the variable via PHP from parent to iFrame.

 

I'll keep searching for a solution. But thank you again for your quick and accurate reply!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.