Answers for "php remove file extension"

PHP
10

php remove file

if(file_exists($file)) {
	unlink($file);
}
Posted by: Guest on January-13-2020
1

php regex remove file extension

$withoutExt = preg_replace('/\\.[^.\\s]{3,4}$/', '', $filename);

This matches a dot followed by three or four characters which are not a dot or a space.
Posted by: Guest on June-19-2020
0

remove .php extension

#This code will automatically remove .php extention
#ex: it remmoves www.eample.com/xyz.php to www.example.com/xyz
RewriteEngine on
RewriteBase /
RewriteRule ^(.+)\.php$ /$1 [R,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ /$1.php [NC,END]

#Copy and paste the above code in .htaccess file
Posted by: Guest on June-01-2021

Code answers related to "php remove file extension"

Browse Popular Code Answers by Language