URL Helper Test (Codeigniter Example)
In the application/config/autoload.php file edit the following line as follow
$autoload['helper'] = array('url');
In the Controller i have created a controller the file name is urlhelpertest.php and the code is as follow:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Urlhelpertest extends CI_Controller
{
public function index()
{
$this->load->view('url_test_message');
}
}
In the view folder i have created a file name url_test_message.php and the code is as follow:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>URL Helper Test</title>
</head>
<body>
<?= site_url("welcome"); ?>
<a href="<?= site_url("welcome") ?>">Welcome Page</a>
<br /><br />
<?php
$segment = array("welcome");
echo base_url($segment);
?>
<a href="<?= base_url($segment) ?>">Welcome Page</a>
<br /><br />
<?= current_url(); ?>
<a href="<?= current_url() ?>">Current Page</a>
<br /><br />
<?= uri_string(); ?>
<a href="<?= uri_string() ?>">Current Page</a>
<br /><br />
<?= index_page(); ?>
<!-- Syntax: anchor(uri segments, text, attributes); -->
<?= anchor('useragent', 'User Agent Details', 'title="Details about userdetails"'); ?>
<br /><br />
<?= anchor_popup('sessionauto', 'Session Auto', array()); ?>
<br /><br />
<?php
$atts = array(
'width' => '800',
'height' => '600',
'scrollbars' => 'yes',
'status' => 'yes',
'resizable' => 'yes',
'screenx' => '300',
'screeny' => '50'
);
?>
<?= anchor_popup('sessionauto', 'Session Auto', $atts); ?>
<br /><br />
<?= mailto('me@my-site.com', 'Click Here to Contact Me'); ?>
<br /><br />
<?= safe_mailto('me@my-site.com', 'Click Here to Contact Me'); ?>
<br /><br />
</body>
</html>
$autoload['helper'] = array('url');
In the Controller i have created a controller the file name is urlhelpertest.php and the code is as follow:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Urlhelpertest extends CI_Controller
{
public function index()
{
$this->load->view('url_test_message');
}
}
In the view folder i have created a file name url_test_message.php and the code is as follow:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>URL Helper Test</title>
</head>
<body>
<?= site_url("welcome"); ?>
<a href="<?= site_url("welcome") ?>">Welcome Page</a>
<br /><br />
<?php
$segment = array("welcome");
echo base_url($segment);
?>
<a href="<?= base_url($segment) ?>">Welcome Page</a>
<br /><br />
<?= current_url(); ?>
<a href="<?= current_url() ?>">Current Page</a>
<br /><br />
<?= uri_string(); ?>
<a href="<?= uri_string() ?>">Current Page</a>
<br /><br />
<?= index_page(); ?>
<!-- Syntax: anchor(uri segments, text, attributes); -->
<?= anchor('useragent', 'User Agent Details', 'title="Details about userdetails"'); ?>
<br /><br />
<?= anchor_popup('sessionauto', 'Session Auto', array()); ?>
<br /><br />
<?php
$atts = array(
'width' => '800',
'height' => '600',
'scrollbars' => 'yes',
'status' => 'yes',
'resizable' => 'yes',
'screenx' => '300',
'screeny' => '50'
);
?>
<?= anchor_popup('sessionauto', 'Session Auto', $atts); ?>
<br /><br />
<?= mailto('me@my-site.com', 'Click Here to Contact Me'); ?>
<br /><br />
<?= safe_mailto('me@my-site.com', 'Click Here to Contact Me'); ?>
<br /><br />
</body>
</html>
Comments
Post a Comment