如果URL有前缀,则执行PHP

I have multiple pages with the magic prefix, the URL is like so for the main page:

dashboard.php?page=magic

and for the other subpages like so:

dashboard.php?page=magic_dothisandthat

but that way I have to add them all to my stylesheet execution script;

if(isset($_GET['page']) && $_GET['page'] == 'magic') {
     '<link rel="stylesheet" href="example">';
}

Is there a way to execute the stylesheet HTML on all pages which have the magic_ prefix?

Example what I mean:

if($_GET['page'] == 'magic_' *) {

You can check if the first 5 characters of $page equal magic:

if(isset($_GET['page']) && substr($_GET['page'],0,5) == 'magic') {
     '<link rel="stylesheet" href="example">';
}

http://php.net/manual/en/function.substr.php

Use strpos to see if it's the the magic_ prefix is at the first index.

if (strpos($_GET['page'], 'magic_') === 0) {
  echo '<link rel="stylesheet" href="example">';
}