php class Service public function __construct url this- url url protec

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
class Service
{
public function __construct( $url )
{
$this->url = $url;
}
protected function correctPaths()
{
foreach( $this->images as $id => $image )
{
if( substr( $image, 0, 1 ) == '/' )
{
$this->images[$id] = preg_replace( '#(http://[^/]+).*#sim', '\\1', $this->url ) . $image;
}
if( substr( $image, 0, 7 ) != 'http://' && substr( $image, 0, 1 ) != '/' )
{
$this->images[$id] = substr( $this->url, 0, strrpos( $this->url, '/' ) + 1 ) . $image;
}
}
}
}
?>