Category Archives: PHP

Post related to PHP

simple crud on codeigniter

sql: CREATE TABLE IF NOT EXISTS `tbl_person` (   `id` bigint(20) NOT NULL AUTO_INCREMENT,   `name` varchar(50) DEFAULT NULL,   `gender` char(1) DEFAULT NULL,   `dob` date DEFAULT NULL,   PRIMARY KEY (`id`) ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ; INSERT … Continue reading

Posted in PHP | Tagged | 2 Comments

reading of soap xml response by xpath

xml response: <?xml version=”1.0″ encoding=”UTF-8″?> <SOAP-ENV:Envelope xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/&#8221; xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns:SOAP-ENC=”http://schemas.xmlsoap.org/soap/encoding/”&gt; <SOAP-ENV:Body SOAP-ENC:encodingStyle=”http://schemas.xmlsoap.org/soap/envelope/”&gt; <NS1:IsWorkingResponse xmlns:NS1=”urn:MobileCommIntf-IMobileComm”> <return xsi:type=”xsd:boolean”>true</return> </NS1:IsWorkingResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> php code : $xml = simplexml_load_string($output); $xml->registerXPathNamespace(‘SOAP-ENV’, ‘http://schemas.xmlsoap.org/soap/envelope/&#8217;); $xml->registerXPathNamespace(‘NS’, ‘urn:MobileCommIntf-IMobileComm’); $nodes = $xml->xpath(‘//SOAP-ENV:Envelope/SOAP-ENV:Body/NS:IsWorkingResponse/return’); print_r($nodes[0]->asXML());   http://stackoverflow.com/questions/3928350/how-to-parse-soap-response-without-soapclient  

Posted in PHP | 2 Comments

php making of django like template system with extend

add this class Template : class Template {     const DIRECTORY = ”;     protected $path;     protected $extendedTemplate = null;     protected $sections = array();     protected $currentSection = null;     public function extend( $name )     {         … Continue reading

Posted in PHP | 1 Comment

making own mvc framework in php

include these two classes will make Request Class : <?php Class Request {     private $_controller;     private $_method;     private $_args;     public function __construct(){         $str=$_SERVER[‘REQUEST_URI’];        // echo “<pre>”;         //print_r($_SERVER);         $first_slash = strpos($str, ‘/’);         … Continue reading

Posted in PHP | 1 Comment

php Writing of Word Document

main.php $html = get_include_contents(‘test.php’); file_put_contents(“wor33d.doc”, $html); function get_include_contents($filename) {     if (is_file($filename)) {         ob_start();         include $filename;         return ob_get_clean();     }     return false; } test .php <?php echo $html='<!DOCTYPE html> <html> <body> <h1>My First Headidsdfsng</h1> <p>My first … Continue reading

Posted in PHP, Uncategorized | Leave a comment

how to enable curl in php

sudo emacs /etc/php5/apache2/php.ini extension=php_curl.dll on debian : nice method . apt-get install php5-curl /etc/init.d/apache2 restart Ref :  http://stackoverflow.com/questions/1347146/how-to-enable-curl-in-php

Posted in PHP, Ubuntu/Linux | Leave a comment

Setting header for creating xml file

Setting header for creating xml file <?php // Send the headers header(‘Content-type: text/xml’); header(‘Pragma: public’); header(‘Cache-control: private’); header(‘Expires: -1’); echo “<?xml version=\”1.0\” encoding=\”utf-8\”?>”; echo ‘<xml>’; // echo some dynamically generated content here /* <track>     <path>song_path</path>     <title>track_number … Continue reading

Posted in PHP | Leave a comment

For Handling PUT and DELETE for REST API in CURL

Use CURLOPT_CUSTOMREQUEST = ‘DELETE’ CURLOPT_CUSTOMREQUEST = ‘PUT’ Ref : http://stackoverflow.com/questions/2081894/handling-put-delete-arguments-in-php

Posted in PHP | Leave a comment

simple curl function

function curlsimple($url){ //open connection $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don’t return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => “”, // handle all encodings CURLOPT_USERAGENT => “spider”, // who am … Continue reading

Posted in PHP | Leave a comment

how to pass JSON via curl with php

function jsoncurl($url, $fieldString){ //open connection $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_USERAGENT => “spider”, // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // … Continue reading

Posted in PHP | 1 Comment