Checking if a Host Is Alive

Use PEAR's Net_Ping package:
require 'Net/Ping.php';

$ping = new Net_Ping;
if ($ping->checkhost('www.oreilly.com')) {
    print 'Reachable';
} else {
    print 'Unreachable';
}

$data = $ping->ping('www.oreilly.com');
 
The ping program tries to send a message from your machine to another.
 If everything goes well, you get a series of statistics chronicling the transaction. An error means that ping can't reach the host for some reason.
On error, Net_Ping::checkhost( ) returns false
and Net_Ping::ping( ) returns the constant PING_HOST_NOT_FOUND. If there's a problem running the ping program (because Net_Ping is really just a wrapper for the program), PING_FAILED is returned.
 

Opening a Remote File

You want to open a file that's accessible to you via HTTP or FTP.

Pass the file's URL to fopen( )

$fh = fopen('http://www.example.com/robots.txt','r') or die($php_errormsg);
 
 
When fopen( ) is passed a filename that begins with http://, it retrieves the given page with an HTTP/1.0 GET request (although a Host: header is also passed along to deal with virtual hosts). Only the body of the reply can be accessed using the file handle, not the headers. Files can be read, not written, via HTTP.
When fopen( ) is passed a filename that begins with ftp://, it returns a pointer to the specified file, obtained via passive mode FTP. You can open files via FTP for either reading or writing, but not both.
To open URLs that require a username and a password with fopen( ), embed the authentication information in the URL like this: 

$fh = fopen('ftp://username:password@ftp.example.com/pub/Index','r'); 
$fh = fopen('http://username:password@www.example.com/robots.txt','r');
 
 
Opening remote files with fopen( ) is implemented via a PHP feature 
called the URL fopen wrapper. It's enabled by 
default but is disabled by setting allow_url_fopen to off in 
your php.ini or web server configuration file. If 
you can't open remote files with fopen( ), check your server 
configuration.  

Changing File Permissions by php

Use chmod( ) to change the permissions of a file: 

chmod('/home/user/secrets.txt',0400);
 
Use chown( ) to change a file's owner and chgrp( ) to change a file's group:
<?php 
chown('/tmp/myfile.txt','sklar');           // specify user by name
chgrp('/home/sklar/schedule.txt','soccer'); // specify group by name

chown('/tmp/myfile.txt',5001);              // specify user by uid
chgrp('/home/sklar/schedule.txt',102); 
 // specify group by gid
?> 

The permissions passed to chmod( ) must be specified as an octal number.
The superuser can change the permissions, owner, and group of any file. Other users are restricted. They can change only the permissions and group of files that they own, and can't change the owner at all. Nonsuperusers can also change only the group of a file to a group they belong to.
The functions chmod( ), chgrp( ), and chown( ) don't work on Windows.

XML file using the DOM API

//Use PHP's DOM XML extension. Here's how to read XML from a file:
$dom = domxml_open_file('books.xml');
//Here's how to read XML from a variable:
$dom = domxml_open_mem($books);
//You can also get just a single node. Here's how to get the root node:
$root = $dom->document_element( );
//Here's how to do a depth-first recursion to process all the nodes in a document:
 
function process_node($node) {
    if ($node->has_child_nodes( )) {
        foreach($node->child_nodes( ) as $n) {
            process_node($n);
        }
    }

    // process leaves
    if ($node->node_type( ) =  = XML_TEXT_NODE) {
        $content = rtrim($node->node_value( ));
        if (!empty($content)) {
            print "$content\n";
        }
    }

}
process_node($root);
 
The W3C's DOM provides a platform- and language-neutral method that specifies the structure and content of a document. Using the DOM, you can read an XML document into a tree of nodes and then maneuver through the tree to locate information about a particular element or elements that match your criteria. This is called tree-based parsing . In contrast, the non-DOM XML functions allow you to do event-based parsing.
 

convert time in php

<?php

     $thishour = time() + (4*60*60);

     $newTime = date("d m Y H:i:s",$thishour);

     echo $newTime;

   ?>);

what is ob_start?

ob_start turns on output buffering,

Scope Resolution Operator?

::  is the scope operator it is used to call methods of a class that has not been instantiated.

What is MVC?

MVC- Model, View, Controller - is simply
Model -  contains data access code and all of you business logic code.
View - Contains markup/design code, generally html,xml, json.
Controller -  contains very little code, just whatever is needed to call the Model code and render the View code.

What is SEO Writing?

Article Writing
press release writing
blog writing
web page writing
product description writing

eCommerce Tips

start SEO if you own an eCommerce store. eCommerce shopping is expected to rise
higher than ever before this holiday season.The series of algorithm updates from
Google staring very early this year has made everyone think if they should really focus on
SEO anymore.Social signals have huge importance because the links obtained in social media are mostly natural. Facebook and twitter are without doubt the best social networks available today and when Google says social media links are important for ranking, it is quite natural for everyone to start posting regular tweets and facebook wall updates to get social links.