执行操作URL是在PHP中动态生成的

I don't know how to easily describe this, here goes nothing...

I am writing a PHP script to perform an action if the URL is a specific URL, however, the URL is /ref/[VISITOR_USERNAME]. I want to set it so that anytime the URL is /ref/[ANY_TEXT], the action will perform.

    if($_SERVER['REQUEST_URI'] == '/ref/' . string . '') {
    ...perform action...
}

How do I tell the script that if the URL is /ref/ and anything following that to perform the action?

Also, I realize there are other, probably better ways to do this, but for the sake of what I am trying to do, I need to do it this way.

Thanks in advance.

if(substr($_SERVER['REQUEST_URI'], 0, 5) == '/ref/') {
  ...
}

If you want to check for more you can build a regex:

if(preg_match('/\/ref\/.+/', $_SERVER['REQUEST_URI'])) {
    ...
}

You may just want to revise your Conditional Statement like so:

    <?php
    // CHECK THAT THE REQUEST URL CONTAINS "ref/[ANY_STRING_AT_ALL_INCLUDING_SLASHES]"
    if( preg_match("#ref\/.*#", $_SERVER['REQUEST_URI'])) {
        // NOW,GET TO WORK CODER... ;-)
    }