Tech Touch Online
Monday, May 7, 2012
daily coding
====================================== data wise code (most recent at top)======================================================= Tue May 08,2012 "; echo basename (__FILE__); echo "
"; echo $_SERVER['HTTP_HOST'] ; echo "
"; echo $_SERVER['REQUEST_URI']; echo "
"; echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; echo "
"; function url(){ $protocol = $_SERVER['HTTPS'] ? "https" : "http"; return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } echo url(); echo "
"; echo $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] ?> --------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------- Mon May 07,2012 blog.php -- the controller code load->model('model_welcome'); $content['companyNames']=$this->model_welcome->selectCompany(); $this->load->view('blog_view',$content); } } ?> model class code db_host = "192.168.0.105"; $this->db_port = "5432"; $this->db_name = "liveki20110914"; $this->db_user = "post-db"; $this->db_password = "post"; $this->conn_string = "host=$this->db_host port=$this->db_port dbname=$this->db_name user=$this->db_user password=$this->db_ password"; $this->dbconn = @pg_pconnect($this->conn_string); } function selectCompany() { $s="select companyname from company"; return $this->execute_query($s); } function execute_query($sql) { $res = @pg_query($this->dbconn, $sql); $arr = @pg_fetch_all($res); return $arr; } } //end class Model_welcome ?> view code
codeigniter with database connection
";} ?>
--------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------- Thu May 03,2012 blog.php load->view('blog_view');// 2nd ly i tested with this line $template['title']="my page title modified "; $template['heading']="my page heading modified "; $template['whattodo']=array('codeigniter','raw php','postgresql'); $this->load->view('blog_view', $template); } function test() { echo "test function of blog"; } } ?> blog_view.php
=$title ?>
=$heading?>
=$value?>
--------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------- Wed May 02,2012 "; } } class SubClass extends BaseClass { function __construct() { parent::__construct(); print "construct in sub class
"; } } $baseclass= new BaseClass(); $subclass= new SubClass(); function BaseClass () { this->databasename="sample_db_assad"; echo this-> databasename; } BaseClass(); ?> --------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------- Tue May 01,2012 "; if ($numargs>=2) { echo "the second number is ". func_get_arg(1)."
"; } $arg_list=func_get_args(); for ($i =0;$i<$numargs;$i++) { echo "argument $i is : ". $arg_list[$i]."
"; } } foo(1,2,3); ?> --------------------------------------------------------------------------------------------------------------------------------- "; list ($star,,$season)=$info; echo $star. " comes in ".$season ."
"; list (,,$session) = $info; echo $season . ", i like it "."
"; foreach ($info as $value) { print $value . "
"; } //$browser = get_browser(null, true ); //print_r($browser); echo $_SERVER['HTTP_USER_AGENT'] . "\n\n"; $browser = get_browser(null, true); print_r($browser); ?> --------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------- Mon Apr 30, 2012 name=$nm; } function getName() { return $this->name . "
"; } } $tcip= new TestClassInPhp(); $tcip->setName(" this is an another test item"); print($tcip->getName()); echo $tcip->getName(); ?> --------------------------------------------------------------------------------------------------------------------------------- template.html file
=$SYSN["title"] ?>
=$SYSN["Headline"]?>
=$SYSN["Contents"]?>
variable.php file index.php file --------------------------------------------------------------------------------------------------------------------------------- simple use of :: (scope resolution)operator ".MyClass::CONSTANT_VALUE."
"; class ExampleSuperClass { static function classType() { return " Superclass"; } static function doSomething() { return "do something with " . self::classType() ; } } class ExampleClass extends ExampleSuperClass { static function classType() { return "subclass"; } } echo "
example of superclass , subclass and scope resolution operator :
".ExampleClass::doSomething(); ?> -----------------------------------------------------------------------------------------------------
Newer Post
Older Post
Home
Office Activation