well... PHP_SELF grabs the name of the file your currently executing, so if you run 158.php, PHP_SELF will grab 158.php.
as I stated in the first example assuming $_SERVER['PHP_SELF']; results in something like '/PHPscripts/158.php' you can then use my code to grab 158 or you could modify my code to accomodate what value you receive from PHP_SELF.
try this:
<?php
print $PHP_SELF;
print $_SERVER['PHP_SELF'];
?>
I've tried my code together with yours and it works without problems, so you may be receiving a different value from PHP_SELF.
run the script above and tell me what you see.
quick explaination of the code:
// Assuming you get something like '/PHPscripts/158.php'
// from PHP_SELF.
// this puts the path and filename into an array
// e.g. $get_filename[1] = "PHPscripts";
// e.g. $get_filename[2] = "158.php";
$get_filename = explode("/",$_SERVER['PHP_SELF']);
// this puts the value from $get_filename[2]="158.php"
// into a further array such as;
// $get_id[0] = "158"
// $get_id[1] = "php"
$get_id = explode(".",$get_filename[2]);
// then we use casting to convert $get_id[0]="158" to
// an integer value
$grabid = (integer)$get_id[0];
// then $grabid will store the value 158
HTH