Thursday, October 10, 2013
Saturday, October 05, 2013
namespace in php
namespace in php
<?php
namespace foo;
class Robot {
static function says() {echo 'I am Terminator!';}
}
?>
<?php
namespace bar;
class RoboCop {
static function says() {echo 'I am Robocop!';}
}
?>
<?php namespace terminate;
class Terminator {
static function says() {echo 'Terminator';} }
?>
<?php namespace computer;
class Comp {
static function show() {echo 'I am computer';}
function laptop() { echo "this is laptop ";}
}
?>
<?php
namespace realexample;
//use foo as robo;
//use bar as roboc;
//use terminate;
//echo robo\Robot::says(), "<br />\n";
//echo roboc\RoboCop::says(), "<br />\n";
//echo terminate\Terminator::says(), "<br />\n";
echo \foo\Robot::says(), "<br />\n";
echo \bar\RoboCop::says(), "<br />\n";
echo \terminate\Terminator::says(), "<br />\n";
echo \computer\Comp::show(), "<br />\n";
$comp = new \computer\Comp();
$comp->laptop();
?>
<?php
namespace foo;
class Robot {
static function says() {echo 'I am Terminator!';}
}
?>
<?php
namespace bar;
class RoboCop {
static function says() {echo 'I am Robocop!';}
}
?>
<?php namespace terminate;
class Terminator {
static function says() {echo 'Terminator';} }
?>
<?php namespace computer;
class Comp {
static function show() {echo 'I am computer';}
function laptop() { echo "this is laptop ";}
}
?>
<?php
namespace realexample;
//use foo as robo;
//use bar as roboc;
//use terminate;
//echo robo\Robot::says(), "<br />\n";
//echo roboc\RoboCop::says(), "<br />\n";
//echo terminate\Terminator::says(), "<br />\n";
echo \foo\Robot::says(), "<br />\n";
echo \bar\RoboCop::says(), "<br />\n";
echo \terminate\Terminator::says(), "<br />\n";
echo \computer\Comp::show(), "<br />\n";
$comp = new \computer\Comp();
$comp->laptop();
?>
Open new Windows in jquery and javascript
Open new Windows in jquery and javascript
<!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>Untitled Document</title>
<script src="jquery-1.6.3.min.js" type="text/javascript"></script>
</head>
<body>
<a href="1.html">Click Here</a>
<a href="2.html">Click Here</a>
<script type="text/javascript">
$('a').click(function (event) {
//event.preventDefault();
var myurl = $(this).attr('href');
myurl = "http://www.google.com/";
var left = ($(window).width()/2)-(900/2);
//top = ($(window).height()/2)-(600/2),
var top = 800;
var popup = window.open (myurl, "_blank", "width=900, height=600, top="+top+", left="+left);
popup.blur();
self.focus();
window.open(this.href,'_self');
window.focus();
});
</script>
</body>
</html>
<!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>Untitled Document</title>
<script src="jquery-1.6.3.min.js" type="text/javascript"></script>
</head>
<body>
<a href="1.html">Click Here</a>
<a href="2.html">Click Here</a>
<script type="text/javascript">
$('a').click(function (event) {
//event.preventDefault();
var myurl = $(this).attr('href');
myurl = "http://www.google.com/";
var left = ($(window).width()/2)-(900/2);
//top = ($(window).height()/2)-(600/2),
var top = 800;
var popup = window.open (myurl, "_blank", "width=900, height=600, top="+top+", left="+left);
popup.blur();
self.focus();
window.open(this.href,'_self');
window.focus();
});
</script>
</body>
</html>
openssl_encrypt and openssl_decrypt in PHP
openssl_encrypt and openssl_decrypt in PHP
openssl_encrypt and openssl_decrypt
/*$string = 'This is test';
$pass = '1234';
$method = 'aes128';
file_put_contents ('./file.txt', openssl_encrypt ($string, $method, $pass));*/
$method = 'aes-128-ecb';
$iv = openssl_random_pseudo_bytes(
openssl_cipher_iv_length($ method));
$msg="this is the testing for encoding and decoding";
$en=openssl_encrypt($msg, $method, 'def', true, $iv);
echo $en;
$de=openssl_decrypt($en, $method, 'def', true, $iv);
echo $de;
openssl_encrypt and openssl_decrypt
/*$string = 'This is test';
$pass = '1234';
$method = 'aes128';
file_put_contents ('./file.txt', openssl_encrypt ($string, $method, $pass));*/
$method = 'aes-128-ecb';
$iv = openssl_random_pseudo_bytes(
$msg="this is the testing for encoding and decoding";
$en=openssl_encrypt($msg, $method, 'def', true, $iv);
echo $en;
$de=openssl_decrypt($en, $method, 'def', true, $iv);
echo $de;
Remove Controller and it's method form codeigniter
How to remove Controller in codeigniter and it's method just show it's parameter in url for ex:
http://localhost:90/ CodeIgniter_2.1.4_new/ category/show/this-is-the- test.html
as
http://localhost:90/ CodeIgniter_2.1.4_new/this-is- the-test.html
Goto routes.php under config directory:
write this listed below line
$route['(:any)'] = "category/show/$1";
==============================
============================== ======================
create a new file "category.php"
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Category extends CI_Controller {
public function index() {
$this->load->view('welcome_ message');
}
public function show($text) {
echo "aaaaa".$text;
}
}
http://localhost:90/
as
http://localhost:90/
Goto routes.php under config directory:
write this listed below line
$route['(:any)'] = "category/show/$1";
==============================
create a new file "category.php"
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Category extends CI_Controller {
public function index() {
$this->load->view('welcome_
}
public function show($text) {
echo "aaaaa".$text;
}
}
Send email in Codeigniter
Send email in Codeigniter
$this->load->library('email');
$this->email->from('my@my- site.com', 'My Name');
$this->email->subject('Test subject');
$this->email->message('Testing email.');
$this->email->attach('/path/img1.jpg');
$this->email->send();
$this->load->library('email');
$this->email->from('my@my-
$this->email->subject('Test subject');
$this->email->message('Testing email.');
$this->email->attach('/path/img1.jpg');
$this->email->send();










