API15

JFile/makeSafe: Difference between revisions

From Joomla! Documentation

m removing red link to edit, no existant pages
m preparing for archive only
 
Line 44: Line 44:


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=makeSafe
  category=makeSafe
  category=JFile
  category=JFile
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*

Latest revision as of 00:37, 25 March 2017

Description

Makes file name safe to use

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

makeSafe($file)
Parameter Name Default Value Description
$file $file The name of the file [not full path]

Returns

string The sanitised string

Defined in

libraries/joomla/filesystem/file.php

Importing

jimport( 'joomla.filesystem.file' );

Source Body

function makeSafe($file) {
        $regex = array('#(\.){2,}#', '#[^A-Za-z0-9\.\_\- ]#', '#^\.#');
        return preg_replace($regex, '', $file);
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

Code Examples