Rom VIP Member VIP โ 20 โ Impact 73 Jul 9, 2006 450 views 3 replies #1 Hello, Does anyone know how to turn a file name into a variable? i.e. File name = test.php V $title = "test"; ? Thanks.
Hello, Does anyone know how to turn a file name into a variable? i.e. File name = test.php V $title = "test"; ? Thanks.
maximum VIP Member VIP โ 20 โ Impact 98 Jul 9, 2006 #2 Let us say the current file name this script-bit is in is actually your test.php. <? $this = $PHP_SELF; $showthis = basename($this); $stripthis = basename($this, ".php"); echo $showthis."<br>".$stripthis; ?> produces: test.php test refer to: http://us2.php.net/manual/en/function.basename.php for more tools on using basename() with variables, ect. Last edited: Jul 9, 2006
Let us say the current file name this script-bit is in is actually your test.php. <? $this = $PHP_SELF; $showthis = basename($this); $stripthis = basename($this, ".php"); echo $showthis."<br>".$stripthis; ?> produces: test.php test refer to: http://us2.php.net/manual/en/function.basename.php for more tools on using basename() with variables, ect.
superprogrammer VIP Member VIP โ 20 โ Impact 37 Jul 9, 2006 #3 <? $mystring="file.php"; $filename=explode(".",$mystring); echo $filename[0]; ?>