parent AND self PHP oops

 parent  AND self PHP oops

self::refers to the current class and it is usually used to access
static members, methods, and constants. parent::refers to the
 parent class and it is most often used when wanting to call the
 parent constructor or methods. It may also be used to access
members and constants. You should use parent::as
opposed to the parent’s class name because it makes it easier
 to change your class hierarchy because you are not hard-coding
 the parent’s class name.

The following example makes use of both parent::and self::for
 accessing the Childand Ancestorclasses:

class Ancestor {
const NAME = "Ancestor";
function __construct()
{
print "In " . self::NAME . " constructor\n";
}
}
class Child extends Ancestor {
const NAME = "Child";
function __construct()
{
parent::__construct();
print "In " . self::NAME . " constructor\n";
}
}
$obj = new Child();

The previous example outputs
In Ancestor constructor
In Child constructor
Make sure you use these two class names whenever possible.

Static Methods-PHP

 PHP supports declaring methods as static.
Whatthis means is that your static methods are part of the
 class and are not bound to any specific object instance and
 its properties. Therefore, $this isn’t accessible in these methods,
 but the class itself is by using selfto access it. Because
static methods aren’t bound to any specific object, you can
 call them without creating an object instance by using the
class_name::method()syntax. You may also call them from an
 object instance using $this->method(), but $thiswon’t
be defined in the called method. For clarity, you should use self::method()
instead of $this->method().

class PrettyPrinter {
static function printHelloWorld()
{
print "Hello, World";
self::printNewline();
}
static function printNewline()
{
print "\n";
}
}
PrettyPrinter::printHelloWorld();

The example prints the string "Hello, World"followed by a newline.
Although it is a useless example, you can see that printHelloWorld()can be
called on the class without creating an object instance using the class name,
and the static method itself can call another static method of the
class printNewline()using the self::notation. You may call a parent’s
 static method by using the parent::notation.

Static Properties

As you know by now, classes can declare properties. Each instance of the
class,object has its own copy of these properties. However, a class can
also contain static properties. Unlike regular properties, these belong to
the class itself and not to any instance of it.

class propertiesas opposed to object or instance properties. You can also
think of static properties as global variables that sit inside a class but are
accessible from anywhere via the class.
Static properties are defined by using the static keyword:
class MyClass {
static $myStaticVariable;
static $myInitializedStaticVariable = 0;
}
To access static properties, you have to qualify the property name with
the class it sits in

MyClass::$myInitializedStaticVariable++;
print MyClass::$myInitializedStaticVariable;

What is array

Arrays
An arrayin PHP is a collection of key/value pairs.
 This means that it maps keys or indexes to values.
Array indexescan be either integers or strings
whereas values can be of any type.
Arrays in PHP are implemented using hash tables, which
 means that accessing a value has an average complexity.

array()construct Arrays can be declared using the array()language
 construct, which generally takes the following form elements inside
square brackets, [], are optional:

array([key =>] value, [key =>] value, ...)

The key is optional, and when it’s not specified, the key is
 automatically assigned one more than the largest previous
 integer key starting with 0. You can intermix the use with
 and without the key even within the same declaration.
The value itself can be of any PHP type, including an array.
 Arrays containing arrays give a similar result as multi-dimensional
 arrays in other languages.

Accessing Array Elements Array elements can be accessed by using
the $arr[key]notation, where keyis either an integer or string expression.
When using a constant string for key,make sure you don’t forget the single or
double quotes, such as $arr["key"]. This notation can be used for both reading
array elements and modifying or creating new elements.

$arr1 = array(1, 2, 3);
$arr2[0] = 1;
$arr2[1] = 2;
$arr2[2] = 3;
print_r($arr1);
print_r($arr2);

The print_r()function has not been covered yet in this book, but when it
is passed an array, it prints out the array’s contents in a readable way. You can
use this function when debugging your scripts.

Array
(
[0] => 1
[1] => 2
[2] => 3
)
Array
(
[0] => 1
[1] => 2
[2] => 3
)
So, you can see that you can use both the array()construct
 and the $arr[key] notation to create arrays.
Usually, array()is used to declare arrays
whose elements are known at compile-time, and
 the $arr[key]notation is used when the elements
 are only computed at runtime.
PHP also supports a special notation, $arr[], where the key is
 not specified. When creating new array offsets using
 this notation , the key is automatically assigned as one
 more than the largest previous integer key.

Therefore, the previous example can be rewritten as follows:
$arr1 = array(1, 2, 3);
$arr2[] = 1;
$arr2[] = 2;
$arr2[] = 3;

$arr1 = array("name" => "John", "age" => 28);
$arr2["name"] = "John";
$arr2["age"] = 28;
if ($arr1 == $arr2) {
print '$arr1 and $arr2 are the same' . "\n";
}

Reading array values You can use the
 $arr[key]notation to read array values.
The next few examples build on top of the previous example:
print $arr2["name"];
if ($arr2["age"] < 35) {
print " is quite young\n";
}
Php Interview-questions-with-answers
Php code for valid number
Php file uploading code
Php by code
Advanced php
Php global variables
Top 550 php interview-questions

PHP Functions
Php tutorial - imagemagick
php.ini Basics
PHP Sessions
Cookies Versus Sessions
PHP Web-Related Variables
PHP ERRORS
maximum size of a file uploaded
Php Image upload
php file_get_contents
MySQL Data on the Web
What are GET and POST
php and pdf
$_ENV and $_SERVER
PEAR with php
SELECTING DATA PHP
prevent hijacking with PHP
LAMP
PHP MySQL Functions
PHP Zip File Functions
Substrings PHP
PHP Variable names
PHP magic methods
How to get current session id
Add variables into a session
$_GET , $_POST,$_COOKIE
different tables present in mysql
PHP CURL
php Sessions page
PHP-sorting an array
PHP-count the elements of array
Operators for If/Else Statements
PHP file uploading code
PHP global variables
Testing working using phpinfo
PHP Code for a Valid Number
PHP-Associative Arrays
PHP mvc tutorial
PHP get_meta_tags-Extracts
difference between print and echo
PHP best tutorial-PHP variables
Reading DOC file in PHP
PHP interview questions
convert time PHP
PHP implode array elements
header function-PHP
PHP-Renaming Files Directories
PHP Classes
in_array function in PHP
keep your session secure PHP
Web Application with PHP
What is SQL Injection
PHP-extract part of a string
PHP urlencode
PHP- know browser properties
PHP- Extracting Substrings
Checking Variable Values /Types
PHP-best 20 Open Source cms
IP AddressPHP
PHP-Scope Resolution Operator
how create new instance of object
how eliminate an object
PHP- ob_start
XML file using the DOM API
PHP- MVC
PHP- CAPTCHA
PHP- Position of a Value in an Array
PHP-Mail Functions
PHP-difference include vs require
calculate the sum of values in an array
PHP-total number of rows
Show unique records mysql
MySQL Triggers
MySQL data directory
MySQL Subqueries
PHP- Networking Functions
PHP- Operators
Restore database
Conditional Functions mysql
PHP-function overloading
Friend function
mysql_connect /mysql_pconnect
PHP-Error Control Operators
what is IMAP
Apache-Specific Functions
Send Email from a PHP Script
SQL inherently
WAMP, MAMP, LAMP
Php tutorial-SYMBOLS
Table Types-MySQL
PHP-Encryption data management
PHP Array
Running MySQL on Windows
Maximum Performance MySQL
XML-RPC
PHP-static variables
Advanced Database Techniques
FTP
Codeigniter
Apache Pool Size
Why NoSQL
MySQL Server Performance
Database software
SQL Interview Answers
PHP Redirect
PHP Interview Questions with Answers
Advanced PHP

strtotime php-current time zone

strtotime()parsing is always done with the current time zone,
unless a different time zone is specified in the string that is parsed:
<?php
echo date("H:i T\n", strtotime("09:22")); // shows 09:22 CET
echo date("H:i T\n\n", strtotime("09:22 GMT")); // shows 10:22 CET
echo gmdate("H:i T\n", strtotime("09:22")); // shows 08:22 GMT
echo gmdate("H:i T\n", strtotime("09:22 GMT")); // shows 09:22 GMT
?>

Using the strtotime()function is easy. It accepts two parameters: the
string to parse to a timestamp and an optional timestamp. If the
 timestamp is included, the time is converted relative to the
 timestamp; if it’s not included,the current time is used. The relative
 calculations are only written with yesterday, tomorrow, and the 1
 year 2 days ago format strings.


Showing the Local Time in Other Time Zones

Showing the Local Time in Other Time Zones Sometimes, you want
 to show a formatted time in the current time zone and in
other time zones as well. The following script shows a full textual
date representation for the U.S., Norway, the Netherlands, and Israel:

<?php
echo strftime("%c\n");
echo "\nEST in en_US:\n";
setlocale(LC_ALL, "en_US");
putenv("TZ=EST");
echo strftime("%c\n");
echo "\nMET in nl_NL:\n";
setlocale(LC_ALL, "nl_NL");
putenv("TZ=MET");
echo strftime("%c\n");
echo "\nMET in no_NO:\n";
setlocale(LC_ALL, "no_NO");
putenv("TZ=MET");
echo strftime("%c\n");
echo "\nIST in iw_IL:\n";
setlocale(LC_ALL, "iw_IL");
putenv("TZ=IST");
echo strftime("%c\n");
?>

Create Login page php-Php code

 Create Login page php

<?php
            session_start();
            $host="localhost"; // Host name
            $username="username"; // Mysql username
            $password="********"; // Mysql password
            $db_name="joinfbla_services"; // Database name
            $tbl_name="members"; // Table name

            // Connect to server and select databse.
            mysql_connect("$host", "$username", "$password")or die("cannot connect");
            mysql_select_db("$db_name")or die("cannot select DB");

            // Define $myusername and $mypassword
            $myusername=$_POST['myusername'];
            $mypassword=$_POST['mypassword'];

            // To protect MySQL injection (more detail about MySQL injection)
            $myusername = stripslashes($myusername);
            $mypassword = stripslashes($mypassword);
            $myusername = mysql_real_escape_string($myusername);
            $mypassword = mysql_real_escape_string($mypassword);
            $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
            $result=mysql_query($sql);

            // Mysql_num_row is counting table row
            $count=mysql_num_rows($result);

            // If result matched $myusername and $mypassword, table row must be 1 row
            if($count==1){

            // Register $myusername, $mypassword and redirect to file "login_success.php"
            $_SESSION['myusername'] = $_POST['myusername'];
            $_SESSION['mypassword'] = $_POST['mypassword'];
            echo 'success';
            }

            else {
            echo "Wrong Username or Password";
            }
        ?>

Php Interview-questions-with-answers
Php code for valid number
Php file uploading code
Php by code
Advanced php
Php global variables
Top 550 php interview-questions


PHP RSS feed script

PHP RSS feed script
RSS Reader PHP code

function get_feed($link)
{

    $this->load->helper('text');

    $last_update = time();

    header('Cache-Control: no-cache, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Content-type: application/json');

    // Load RSS Parser
    $this->load->library('rssparser');

    // Get 6 items from arstechnica
    $rss = $this->rssparser->set_feed_url($link)->set_cache_life(30)->getFeed(5);

    foreach ($rss as $item)
    {

        $pubdate = strtotime($item['pubDate']);
        $monthName = date("F", mktime(0, 0, 0, date("m",$pubdate), 10));
        $new_date = date("d.",$pubdate).' '.$monthName.' '.date("Y",$pubdate).' '.date("H:i",$pubdate);

        $array[] = array(
            'title' => $item['title'],
            'description' => character_limiter($item['description'],100),
            'author' => $item['author'],
            'pubDate' => $new_date,
            'link' => $item['link']
        );
    }

    $array = json_encode($array);

    return $array;
}

Php Interview-questions-with-answers
Php code for valid number
Php file uploading code
Php by code
Advanced php
Php global variables
Top 550 php interview-questions

PHP Functions
Php tutorial - imagemagick
php.ini Basics
PHP Sessions
Cookies Versus Sessions
PHP Web-Related Variables
PHP ERRORS
maximum size of a file uploaded
Php Image upload
php file_get_contents
MySQL Data on the Web
What are GET and POST
php and pdf
$_ENV and $_SERVER
PEAR with php
SELECTING DATA PHP
prevent hijacking with PHP
LAMP
PHP MySQL Functions
PHP Zip File Functions
Substrings PHP
PHP Variable names
PHP magic methods
How to get current session id
Add variables into a session
$_GET , $_POST,$_COOKIE
different tables present in mysql
PHP CURL
php Sessions page
PHP-sorting an array
PHP-count the elements of array
Operators for If/Else Statements
PHP file uploading code
PHP global variables
Testing working using phpinfo
PHP Code for a Valid Number
PHP-Associative Arrays
PHP mvc tutorial
PHP get_meta_tags-Extracts
difference between print and echo
PHP best tutorial-PHP variables
Reading DOC file in PHP
PHP interview questions
convert time PHP
PHP implode array elements
header function-PHP
PHP-Renaming Files Directories
PHP Classes
in_array function in PHP
keep your session secure PHP
Web Application with PHP
What is SQL Injection
PHP-extract part of a string
PHP urlencode
PHP- know browser properties
PHP- Extracting Substrings
Checking Variable Values /Types
PHP-best 20 Open Source cms
IP AddressPHP
PHP-Scope Resolution Operator
how create new instance of object
how eliminate an object
PHP- ob_start
XML file using the DOM API
PHP- MVC
PHP- CAPTCHA
PHP- Position of a Value in an Array
PHP-Mail Functions
PHP-difference include vs require
calculate the sum of values in an array
PHP-total number of rows
Show unique records mysql
MySQL Triggers
MySQL data directory
MySQL Subqueries
PHP- Networking Functions
PHP- Operators
Restore database
Conditional Functions mysql
PHP-function overloading
Friend function
mysql_connect /mysql_pconnect
PHP-Error Control Operators
what is IMAP
Apache-Specific Functions
Send Email from a PHP Script
SQL inherently
WAMP, MAMP, LAMP
Php tutorial-SYMBOLS
Table Types-MySQL
PHP-Encryption data management
PHP Array
Running MySQL on Windows
Maximum Performance MySQL
XML-RPC
PHP-static variables
Advanced Database Techniques
FTP
Codeigniter
Apache Pool Size
Why NoSQL
MySQL Server Performance
Database software
SQL Interview Answers
PHP Redirect
PHP Interview Questions with Answers
Advanced PHP

Twitter Bot

Twitter Bot that allows you to auto follow target twitter users, send
 out tweets automatically. Great for auto twitter retweet. Twitter Cards
 offer a fast and easy way to grow your user base for mobile apps.
 Simply add some new markup to your pages: when users tweet
 links to your domain.twitter account maker you can use Your own
domain, then install catchall on it: Make 1 email called catchall with
 a password, then go to Default Email adress.
Twitter Bots - ranging from auto reply bots and announcement
bots, all tested and working nicely.
Twitter bots are, essentially, computer programs that tweet of their
 own accord. While people access Twitter through its Web site
and other clients, bots connect.If you have a Twitter account, the
chances are that you have fewer than 50 followers and that you
 follow fewer than 50 people yourself. Twitter followers with links
 to diet sites, specious videos, or links to "pics"? You're not alone.
 From the slew of sketchy Direct Messages.
Twitter tools for seo techniques

Key of Seo Success

You actually need people
to visit your website unless you’re some sort of a weirdo who
 only gets excited about showing up on
Google page 1 for its own sake.
I’d like you to indulge me by participating in an experiment .
1.  Search on something that matters to you.   Maybe a hobby,
a band, a place you want to move to, whatever.
2.  When you get to the SERP, click on the entry that you think best
 matches what you’re looking for.
3.  Come back here when you’re done.
What was your experience like?  More specifically, what did you click
 on?  Why did you click on it?If you’re like me there’s a good
chance you did not just click on any old random entry.  You probably
did a quick evaluation based on what the entry looked like.

Forget about writing your content around “keywords”
  Instead, determine the theme that contains the keywords that
 are important to you and write for that theme, not those
 keywords subtle but important difference.

  Think like a human and write like a human.  Google and the
 rest are catching up to you, and if you write good content
 for humans it will pay off down the road.

After you write content, read it.  Out loud.  A couple of times.
 If it sounds awkward to you, it probably will to Google as well.
 Revise it .

Increasingly SEO is about creating content that is high quality.
 I advise you to create content that is themed according to your
 target keywords, but which is also engaging to human visitors.
  An important point of creating that interest is photography.
 So it’s only natural that we would be tempted to snag photos
 from a Google or Bing image search.  At the same time, when quality photos
can be purchased very cheaply, so the temptation is pretty minimal.

seo google
seo guide
seo-consultant
html-intro
html-tags
Why html
Power seo strategies
Best seo articles
seo tips for google
Why email-newsletters
What is character-entities
structure urls
key-factors of link
right-keywords
SEO ranking algorithm
seo research and analysis
seo sources
Top search engine ranking factors
off page seo tips

codeigniter-Creating loops

Creating loops in view files has been a stumbling block for a few developers. By
passing a multidimensional array to a view file, you can easily establish a loop in
any of your view files. Let's take a look at an example.
<?php
class Todo extends Controller
{
function index()
{
$data['todo_list'] = array("buy food", "clean up", "mow lawn");
$this->load->view('todo', $data);
}
}
?>
This is a very simple Controller. Your view file for this would be as follows:
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<h1><?php echo $heading; ?></h1>
<?php echo $content;?>
<h2>My Todo List</h2>
<?php
foreach($todo_list as $item)
{
echo $item;
}
?>
</body>
</html>

Returning views as data
Youare also able to return view files as data; this can be useful if you wish to process
this data in some way. Simply set the third parameter to boolean TRUE—and it will
return the view data.

$this->load->view('welcome', NULL, TRUE);

CodeIgniter uses an output buffer to take all calls to the load view function, and
processes them all at once, sending the whole page to the browser at the same time.
So when you return views as data, you will be able to save the contents of theview
inside a variable for whatever use you need.