So that code is essentially all you need. Use the one I posted with the string to lower…
Here’s your version “fixed”. PHP is a language where double quotes and single-quotes actually mean something unless they’ve changed it. But, back in 4 and 5 days, double quotes actually got “parsed” whereas single-quotes are literal, therefore faster.
What this simple script does is it gets passed the map by gmod ( or anyone wanting to try x-site scripting/injection ), the script then defines the maps array, defines map as the getter from the URL ( you know those things you see in the url like ?xxx=123 and &xyz=321 ); ? is the FIRST argument whereas & represents > 1, so “unlimited” arguments can be passed using ? as first, then & for each variable thereafter. so ?xxx=123 is a _GET[ ‘xxx’ ] and its value is 123, so the same thing occurs with map.
you’re just assigning it to a variable because it gets repeated… I changed it a bit so it checks the isset first; important. Then it defines it as we need it. Then it checks if it is in the array ( if you’re really craving nano-seconds you can put the maps array inside the isset… ), if it is in the array then include that php file…
So, make sure you create a rooftops.php and scrapmetal.php in the same directory as this, or you can have it include from a sub-directory… use a single . to concatenate scripts, use ’ 's.
php is essentially a pre-processor for html that allows more flexibility and dynamic content. It can even be used with ajax to have a seamless and quite nice integration. So a php file can contain nothing but HTML; so for your two php files make an html page.
$maps = array(
'bf_skyscrapers' => 'rooftops.php',
'bf_scrapmetal' => 'scrapmetal.php',
if( isset( $_GET[ ‘map’ ] ) )
map = strtolower( _GET[ ‘map’ ] );
if ( in_array( $map, $maps ) )
include( maps[ _GET[ ‘map’ ] ] );
If you want to start going a little more in depth. Make this the default content for your loading pages:
include( 'header.php' );
include( 'footer.php' );
That’s your very first very BASIC template system. A header and footer is all you really need; the content can be added in the center… With divs you have more freedom too. You can even get more complicated like phpBB, vBulletin, ACMS ( mine ) and others have done by creating plain-text variables that get replaces. It could be something like:
Which then opens 3 files based on whatever. Header could have more of those, content too, footer too.
PHP is a fun language, I recommend it.