The name of my index.php file, I need to make index.txt
<?php $filename = basename(__FILE__); echo $filename; ?> Please help me fix the code.
The name of my index.php file, I need to make index.txt
<?php $filename = basename(__FILE__); echo $filename; ?> Please help me fix the code.
<?php $filename = basename(__FILE__); echo $filename; $withoutExt = preg_replace('/\\.[^.\\s]{3,4}$/', '', $filename); echo $withoutExt; ?> Use pathinfo () :
$filename = pathinfo(__FILE__, PATHINFO_FILENAME) . '.txt'; echo $filename; $filename = basename(__FILE__, ".php"). '.txt'; Source: https://ru.stackoverflow.com/questions/973152/
All Articles