Location: PHPKode > scripts > Link converter > convertir_enlace_ref.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>convertir_enlace class Reference</title>
<style type='text/css'>
body{
	font-family: Arial, Helvetica, sans-serif;
}
h1, h2, h3 {
	margin-bottom: 5px;
}
h1{
	font-size: 15pt;
	border-bottom: solid 1pt black;
	background-color: #cccccc;
}
h2{
	font-size: 13pt;	
}
h3{
	font-size: 11pt;	
	margin-top: 10px;
}
.param, .param_desc, .normal, .bquo{
	font-size: 10pt;	
	margin-top: 3px;
	margin-bottom: 3px;	
}
.param_desc{
	margin-left: 20px;	
	text-indent: 10pt;
}
.header{
	background-color: #eecccc;
}
.firma{
	font-size: 9pt;	
	margin-top: 3px;
	text-align:right;
}
.top{
	text-align:center;
	font-size: 15pt;
	font-weight: bold;
}
.menu{
	font-size: 10pt;
	border-width: 2px;
	border-style: inset;
}
.solapa{
	background-color:#eeeeee;
	font-size: 11pt;
	text-align:center;
}
.solapatras{
	background-color:#bbbbbb;
	font-size: 11pt;
	text-align:center;
	
}
.menuitem{
	font-size: 10pt;
}
.menuitem:hover{
	background-color: #ffcccc;	
}
.cuidado{
 	font-size: 10pt;
	border: 2px solid red;
	background-color: #FFFFEE;
	padding:5px;
	margin:20px;
}
.celda_enc, .celda_bod{
	border: 1px solid black;
 	font-size: 10pt;
	padding:2px;	
}
.celda_enc{
	text-align:center;
	font-weight:bold;
}
</style>
</head>
<body>
<h1>convertir_enlace</h1><h2>Description</h2><p class="normal">Constructor method. <br> It determines the object's link properties</p><h2>Returned value</h2><p class="normal">It does not return</p><h2>Usage</h2><p class="normal">null $obj-&gt;<strong>convertir_enlace</strong> ( [ string<i> link</i> [, bool<i> toUrl</i>] ] );</p><h2>Arguments</h2><p class="param">link</p><p class="param_desc">Optional.A path or url as object's root. If it is not setted $_SERVER["PHP_SELF"] wil be assumed</p><p class="param">toUrl</p><p class="param_desc">Optional.If it is set to false, 'es' property will be a relative path, either it will be a url</p><h2>Examples</h2><h3>Example 1</h3><code>$este = new convertir_enlace('C:/Inetpub/wwwroot/mypath/this.php');<br>
print $este-&gt;es; //it will output something like 'http://localhost/mypath/this.php' if directory exists
</code><h1>desde_ruta</h1><h2>Description</h2><p class="normal">Converts path to url</p><h2>Returned value</h2><p class="normal">It will return a url or, on failure, it will add and entry in 'log' property and return FALSE</p><h2>Usage</h2><p class="normal">null $obj-&gt;<strong>desde_ruta</strong> ( string<i> link</i>);</p><h2>Arguments</h2><p class="param">link</p><p class="param_desc">A path to convert</p><h2>Examples</h2><h3>Example 2</h3><code>$este = new convertir_enlace('C:/Inetpub/wwwroot/mypath/this.php');<br>
print $este-&gt;desde_ruta('../otherpath'); //it will output something like 'http://localhost/otherpath'
</code><h1>desde_url</h1><h2>Description</h2><p class="normal">Converts url to relative path</p><h2>Returned value</h2><p class="normal">It will return a relative path, on failure, it will add and entry in 'log' property and return FALSE</p><h2>Usage</h2><p class="normal">null $obj-&gt;<strong>desde_url</strong> ( string<i> link</i>);</p><h2>Arguments</h2><p class="param">link</p><p class="param_desc">An url to convert</p><h2>Examples</h2><h3>Example 3</h3><code>$este = new convertir_enlace('C:/Inetpub/wwwroot/mypath/this.php');<br>
print $este-&gt;desde_url('http://localhost/otherpath');<br>
//it will output '../otherpath'
</code><h1>este</h1><h2>Description</h2><p class="normal">information about the object's directory root, it is defined during the construction</p><h2>Returned value</h2><p class="normal">array of information of the object's directory root</p><h2>Examples</h2><h3>Example 4</h3><code>$este = new convertir_enlace();<br>
print nl2br(print_r($enste-&gt;este,true));<br>
/* It wil output<br>
Array<br>
(<br>
&nbsp;&nbsp;&nbsp;[raiz] =&gt; C:\Inetpub\wwwroot<br>
&nbsp;&nbsp;&nbsp;[relativa] =&gt; /mypath<br>
&nbsp;&nbsp;&nbsp;[url] =&gt; http://localhost/mypath/<br>
&nbsp;&nbsp;&nbsp;[url_arr] =&gt; Array<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[scheme] =&gt; http<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[host] =&gt; localhost<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[path] =&gt; /mypath/<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br>
&nbsp;&nbsp;&nbsp;[ruta] =&gt; C:\Inetpub\wwwroot/maypath<br>
&nbsp;&nbsp;&nbsp;[esquema] =&gt; C<br>
)<br>
*/</code><p class="param_desc">Naturally, it will depends on system and real location of script</p><p>
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.
</p><h1>log</h1><h2>Description</h2><p class="normal">information about the object's error and warnings</p><h2>Returned value</h2><p class="normal">array of error entries accumulated durin methods usage</p><h2>Examples</h2><h3>Example 5</h3><code>
$este = new convertir_enlace();<br>
$baddir = $este-&gt;desde_rute('../../../../undefined/dir');<br>
print nl2br(print_r($enste-&gt;log,true));<br>
/* It wil output<br>
Array<br>
(<br>
[0] =&gt; Path is deeper than url in ../../../../undefined/dir<br>
)<br>

*/</code>
Return current item: Link converter