Constructor method.
It determines the object's link properties
It does not return
null $obj->convertir_enlace ( [ string link [, bool toUrl] ] );
link
Optional.A path or url as object's root. If it is not setted $_SERVER["PHP_SELF"] wil be assumed
toUrl
Optional.If it is set to false, 'es' property will be a relative path, either it will be a url
$este = new convertir_enlace('C:/Inetpub/wwwroot/mypath/this.php');
print $este->es; //it will output something like 'http://localhost/mypath/this.php' if directory exists
Converts path to url
It will return a url or, on failure, it will add and entry in 'log' property and return FALSE
null $obj->desde_ruta ( string link);
link
A path to convert
$este = new convertir_enlace('C:/Inetpub/wwwroot/mypath/this.php');
print $este->desde_ruta('../otherpath'); //it will output something like 'http://localhost/otherpath'
Converts url to relative path
It will return a relative path, on failure, it will add and entry in 'log' property and return FALSE
null $obj->desde_url ( string link);
link
An url to convert
$este = new convertir_enlace('C:/Inetpub/wwwroot/mypath/this.php');
print $este->desde_url('http://localhost/otherpath');
//it will output '../otherpath'
information about the object's directory root, it is defined during the construction
array of information of the object's directory root
$este = new convertir_enlace();
print nl2br(print_r($enste->este,true));
/* It wil output
Array
(
[raiz] => C:\Inetpub\wwwroot
[relativa] => /mypath
[url] => http://localhost/mypath/
[url_arr] => Array
(
[scheme] => http
[host] => localhost
[path] => /mypath/
)
[ruta] => C:\Inetpub\wwwroot/maypath
[esquema] => C
)
*/
Naturally, it will depends on system and real location of script
convertir_enlace is a class that allows to convert between urls and relative paths. It is very usefull for manage links in html code and to get content of files.
information about the object's error and warnings
array of error entries accumulated durin methods usage
$este = new convertir_enlace();
$baddir = $este->desde_rute('../../../../undefined/dir');
print nl2br(print_r($enste->log,true));
/* It wil output
Array
(
[0] => Path is deeper than url in ../../../../undefined/dir
)
*/