Unstoppable Domains โ€” Get your daily AI drops report

Turning file name into a variable? (PHP)

SpaceshipSpaceship
Watch
Impact
73
Hello,

Does anyone know how to turn a file name into a variable?

i.e.

File name = test.php
V
$title = "test";

?

Thanks.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
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:
0
•••
<?
$mystring="file.php";
$filename=explode(".",$mystring);
echo $filename[0];

?>
 
0
•••
Thanks alot :)
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back