API15

JFile/makeSafe: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: ===Description=== Makes file name safe to use <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </s...
 
m preparing for archive only
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:


<span class="editsection" style="font-size:76%;">
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JFile/makeSafe|Edit Descripton]]<nowiki>]</nowiki>
<nowiki>[<! removed edit link to red link >]</nowiki>
</span>
</span>


{{Description:JFile/makeSafe}}
<! removed transcluded page call, red link never existed >


===Syntax===
===Syntax===
Line 39: Line 39:


<span class="editsection" style="font-size:76%;">
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JFile/makeSafe|Edit See Also]]<nowiki>]</nowiki>
<nowiki>[<! removed edit link to red link >]</nowiki>
</span>
</span>
{{SeeAlso:JFile/makeSafe}}
<! removed transcluded page call, red link never existed >


===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=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>
[[Category:Archived pages API15]]

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