convertir_enlace

Description

Constructor method.
It determines the object's link properties

Returned value

It does not return

Usage

null $obj->convertir_enlace ( [ string link [, bool toUrl] ] );

Arguments

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

Examples

Example 1

$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

desde_ruta

Description

Converts path to url

Returned value

It will return a url or, on failure, it will add and entry in 'log' property and return FALSE

Usage

null $obj->desde_ruta ( string link);

Arguments

link

A path to convert

Examples

Example 2

$este = new convertir_enlace('C:/Inetpub/wwwroot/mypath/this.php');
print $este->desde_ruta('../otherpath'); //it will output something like 'http://localhost/otherpath'

desde_url

Description

Converts url to relative path

Returned value

It will return a relative path, on failure, it will add and entry in 'log' property and return FALSE

Usage

null $obj->desde_url ( string link);

Arguments

link

An url to convert

Examples

Example 3

$este = new convertir_enlace('C:/Inetpub/wwwroot/mypath/this.php');
print $este->desde_url('http://localhost/otherpath');
//it will output '../otherpath'

este

Description

information about the object's directory root, it is defined during the construction

Returned value

array of information of the object's directory root

Examples

Example 4

$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.

log

Description

information about the object's error and warnings

Returned value

array of error entries accumulated durin methods usage

Examples

Example 5

$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
)
*/