Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

PHP isn’t as easy as working with JSON

<?php
$list = array(
"eggs",
"bread",
"milk",
"bananas",
"bacon",
"cheese"
);
$xml = new SimpleXMLElement("<list />");
foreach($list as $item) {
$xml->addChild("item", $item);
}
// for nice output
$dom = dom_import_simplexml($xml)->ownerDocument;
$dom->formatOutput = true;
echo $dom->saveXML();


The starting point is the array that will be our list,
then a SimpleXMLElementobject is
instantiated with a root tag that forms the basis
 for the document. In XML, everything
has to be in a tag so an  <item>tag has been
 introduced in order to contain each list item.
The final block only makes the output prettier,
 which isn’t usually important because
XML is for machines, not for humans.
To get the XML to convert from a  SimpleXM
LElementobject, call the asXML()method
 on that object, which returns a string. The
string, however is all on one line!
The previous example instead converted
 from SimpleXMLElementto DOMElement, and
then grabbed the DOMDocumentfrom that.
 Set the formatOutputto true, so when a call
is made to DOMDocument::saveXML
  to ask it to return the XML as a string), the re‐
sulting output will be nicely formatted.

XML’s abilities to represent attributes, children,
 and character data all provide a more
powerful and descriptive way to represent data
than, for example, JSON. These same
features make XML a great way to represent very
 detailed information, including datatype information,
 so it’s a great choice when those details really do matter.
 It can include
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
information about the types of data and custom data types,
 and each element can have
attributes that cover even more information.

XML in PHP
There are many ways we can work with XML in PHP,
 and they’re all useful in differentsituations. There are
 three main approaches to choose from and they all have their
advantages and disadvantages:








  • PHP: JSON - Manual - PHP: Hypertext Preprocessor

    There are no user contributed notes for this page. Other Basic Extensions. GeoIP; FANN;JSON; Judy; Lua; Misc. Parsekit; SPL; SPL Types; Streams

  • APIs are all about integration between systems and sometimes the choice of data format
    will be dictated by whatever is on the other end of the relationship. XML is particularly
    popular among many enterprise technology platforms such as Java, Oracle, and .NET,





  • JSON with PHP - Tutorials for Sqoop, ITIL, Jackson ...

    This tutorial will teach you how to encode and decode JSON objects using PHPprogramming language. Let's start with preparing environment to start our programming ...
  • Introduction to JSON and PHP - ITNewb: Your Source to ...

    So you've heard the fanfare over JSON, but still haven't had the opportunity to dive into using it. Well, as a matter of fact, you may have been using JSON all along ...
  • PHP: JSON Functions - Manual - PHP: Hypertext …

    Two pure-php implementations of the json protocol that might be of use, e.g. for php 4 installs where adding extensions is not an option or because of extra ...
  • JSON Tutorial - W3Schools Online Web Tutorials

    JSON: JavaScript Object Notation. JSON is a syntax for storing and exchanging data.JSON is an easier to use alternative to XML.
  • PECL :: Package :: json - PECL :: The PHP Extension ...

    This package has been superseded, but is still maintained for bugs and security fixes. Package has moved to channel http://www.php.net/json, package json.
  • How To Parse JSON With PHP - WebDevTutsDepot — …

    Parsing a JSON file or string is just as easy as parsing XML once you get the syntax, and in this tutorial I’ll show you how to parse and learn its syntax.
  • PHP JSON installation and json_decode() function | JSON 

    In this page you will learn about installing JSON in PHP and about PHP json_decode() function with real world examples.
  • AJAX, JSON, jQuery, and PHP - Stack Overflow

    I know there are alot of different questions about this but none
    of them seem to pertain to me. I have an ajax request as follows: var responsePacket; $.ajax ...
  • Working with JSON in PHP jQuery | Packt

    Working with JSON in PHP jQuery written by Vijay Joshi: one of the many articles from Packt Publishing

  • 1. SimpleXMLis the most approachable, and my
     personal favorite. It is easy to use and understand,
     is well documented, and provides a simple interface
     as the namesuggests for getting the job done.
    SimpleXML does have some limitations, but it
    is recommended for most applications.

    2. DOM is handy when a project encounters some
    of the limitations in SimpleXML.It’s more powerful
    and therefore more complicated to use, but there are a small
    number of operations that can’t be done with
     SimpleXML. There are built-in func‐tions to allow
     conversion between these two formats, so it’s very common to use

    Rewriting Keyword-Rich URLs

    rules for your .htaccess file

    Modify the .htaccessfile in your seophpfolder like this:
    RewriteEngine On
    # Rewrite numeric URLs
    RewriteRule ^Products/C([0-9]*)/P([0-9]*)\.html$ i
    /product.php?category_id=$1&product_id=$2 [L]

    # Rewrite keyword-rich URLs
    RewriteRule ^Products/.*-C([0-9]+)/.*-P([0-9]+)\.html$ i
    /product.php?category_id=$1&product_id=$2 [L]

    Load http://test.example.com/Products/Tools-C5/Super-Drill-P9.html

    The new rule matches URLs that start with the string Products/, then contain a number of zero or more
    characters (.*) followed by –C. This is expressed by ^Products/.*-C. The next characters must be one
    or more digits, which as a whole are saved to the $1variable, because the expression is written between
    parentheses — ([0-9]+). This first variable in the URL, $1, is the category ID

    After the category ID, the URL must contain a slash, then zero or more characters (.*), then -P, as expressed
    by /.*-P. Afterward, another captured group follows, to extract the ID of the product, ([0-9]+), which
    becomes the $2variable. The final bit of the regular expression, \.html$, specifies the URL needs to end
    in .html.
    The two extracted values, $1and $2, are used to create the new URL, /product.php?category_id=
    $1&product_id=$2. Figure 3-13 describes the process visually.

    Mysql Join query Codeigniter

    Mysql Join query Codeigniter

    code loads and initializes the database class based on your
    configuration settings.

    $query = $this->db->query('SELECT name, title, email FROM my_table');

    foreach ($query->result() as $row)
    {
        echo $row->title;
        echo $row->name;
        echo $row->email;
    }

    echo 'Total Results: ' . $query->num_rows(); 



    Mysql Join query  Codeigniter


    $this->db->select('*');    
    $this->db->from('tbl1');
    $this->db->join('tbl2', 'tbl1.id = tbl2.id');
    $this->db->join('tbl3', 'tbl1.id = tbl3.id');
    $query = $this->db->get();
     
    The above get() function retrieves all the results
     from the supplied table. 

    Top codeigniter interview question and answers

    codeigniter interview question

     What is codeigniter?
    Codeigniter is open source , web application framework.Its is for building websites using php.Codeigniter is loosely based on MVC pattern.Most simple framework in php , which is you will easily learn.Its mostly known for its speed as compare to other frameworks in php.
    Its goal is to enable you to develop projects much faster than you could if you were writing code from scratch, by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and logical structure to access these libraries.

     When and who developed codeigniter?
    The first public version of CodeIgniter was released on February 28, 2006.

     What are the features of codeigniter?
     Codeigniter is free to use,its an open source framework.
     Its light weight.The core system requires only a few very small libraries.Not like other frameworks that require heavy file libraries.
    Why codeigniter?
     CodeIgniter is Fast.Its faster than any other framework in php.
     The URLs generated by CodeIgniter are clean and search-engine friendly.You will change any url to what ever you want from files.
     CodeIgniter is Extensible.The system can be easily extended through the use of your own libraries, helpers, or through class extensions or system hooks.

    What is MVC
     CodeIgniter Uses MVC(Model View Controller) which allows great separation between logic and presentation.

     CodeIgniter requires nearly zero configuration,does not require you to use the command line,not forced to learn a templating language.

     Full Featured database classes with support for several platforms,Security and XSS Filtering,Error Logging.
     Explain Codeigniter File Structure.

    When you download Codeigniter you will see the following folder structure :-

        application
            cache
            Config
            Controllers
            core
            errors
            helpers
            hooks
            language
            libraries
            logs
            models
            thirdparty
            views
        system
            core
            database
            fonts
            helpers
            language
            libraries
     Explain MVC in Codeigniter.
      Controller:- The Controller serves as an intermediary between the Model
    , the View. controller mediates input, converting it to
    commands for the model or view.

    Model:-The Model represents your data structures. Typically your model classes will contain functions that help you retrieve, insert,
    and update information in your database.The model consists of application data and business rules.

    View:-The View is the information that is being presented to a user. A View will normally be a web page.A view can be any output representation of data.

    What are the hooks in codeigniter?
    CodeIgniter’s Hooks feature provides a means to tap into and modify the inner workings of the framework without hacking the core files.How ever you like to cause some action to take place at a particular stage in the execution process.
    he hooks feature can be globally enabled/disabled by setting the following item in the application/config/config.php file:
    $config['enable_hooks'] = TRUE;

    Hooks are defined in application/config/hooks.php file.For example
        $hook['pre_controller'] = array(
         'class'    =&gt; 'MyClass',
         'function' =&gt; 'Myfunction',
         'filename' =&gt; 'Myclass.php',
         'filepath' =&gt; 'hooks',
         'params'   =&gt; array('test', 'test1', 'webs')
         );

    What are the helpers in codeigniter?
    Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular category.There are URL Helpers, that assist in creating links, there are Form Helpers that help you create form elements, Text Helpers perform various text formatting routines, Cookie Helpers set and read cookies, File Helpers help you deal with files, etc.

    Loading a helper file is quite simple using the following function:
        $this->load->helper('name');

    How you will use or add codeigniter libraries?
    All of the available libraries are located in your system/libraries folder. In most cases, to use one of these classes involves initializing it within a controller using the following initialization function:-
        $this->load->library('class name');

    PHP-final METHODS-override a final method


    However, there are times where you might want to make
    sure that a method cannot be re-implemented in its derived
     classes. For this purpose, PHP supports the Java-like final
    access modifier for methods that declares the method as
    the final version, which can’t be overridden.
    The following example is not a valid PHP script because it is trying to
    override a finalmethod:
    class MyBaseClass {
    final function idGenerator()
    {
    return $this->id++;
    }
    protected $id = 0;
    }
    class MyConcreteClass extends MyBaseClass {
    function idGenerator()
    {
    return $this->id += 2;
    }
    }

    INHERITANCE OF INTERFACES
    Interfaces may inherit from other interfaces. The syntax is
    similar to that of classes, but allows multiple inheritance:

    interface I1 extends I2, I3, ... {
    ...
    }
    Similar to when classes implement interfaces, an interface can only
    extend other interfaces if they don’t clash with each other which means that
    you receive an error if I2defines methods or constants already defined by I1.

    download a file by php code-PHP download files code

    Basic example for download a  file by php

    <?php
    $file="http://testexample.com/your_test_file.jpg"; // path to your file
     header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="'.basename($file).'"');
    header('Content-Length: ' . filesize($file));
    readfile($file); exit;
    ?>

    download a file by php code

    OR

    <?php
    header("Content-Transfer-Encoding: Binary");
            header("Content-length: ".filesize($dest_file_path));
            header('Content-Type: text/xml');
            header('Content-Disposition: attachment; filename="'.$dest_file_name.'"');
            readfile($dest_file_path);
    ?>

    Aarray And multiple array values

    Aarray And multiple array values

    array[key_element1] => array(1, 2,3);
    array[key_element2] => array(4, 5, 6);

     associative arrays
    array[key1] => array(key => value1, key => value2, key => value3);
    array[key2] => array(key => value4, key => value5, key => value6);

    Basically parsing the $values array and pulling the relevant value out.
     Unsetting the array as we go to leave only the values which were not
     sorted. The remaining items in the array will be merged after the loop.
     with array_merge.

    PHP array

    $values = array('value1', 'value2', 'value3', 'value4', 'value5', 'value6');
    $keys = array(0, 2, 1, 5);

    foreach ($keys AS $key) {
        $tempOutput[] = ($values[$key])?$values[$key]:'';
        unset($values[$key]);
    }

    $output = array_merge($tempOutput, $values);


    Make new array be joining 2 arrays
    shuffle($countries);
    $n = count($countries); $i = 0;
    $jumble = array();
    foreach ($names as $name) {
        if (!isset($jumble[$name])) $jumble[$name] = array();
        $jumble[$name][] = $countries[$i++ % $n];
    }

    PHP Session expire-minutes inactivity

    PHP Session expire-minutes inactivity

    session_cache_limiter('public');
    session_cache_expire(15);
    //should expire after 15  minutes inactivity

    asy way to handle this, is to set a variable to $_SESSION
     every time the user visits the page after a successful login.
    You can check that variable every time the page loads, and then
     you will know the last time they requested a page from the site,
     and can compare it to the current time to determine what to do from there.

    session.gc_maxlifetime
    session.gc_maxlifetime specifies the number of seconds after which data
     will be seen as 'garbage' and cleaned up. Garbage collection occurs
     during session start.

    Furthermore, when using PHP's default session.save_handler files,
     the session data is stored in files in a path specified in session.save_path.
     With that session handler, the age of the session data is calculated on the
     file's last modification date and not the last access date.

    if (isset($_SESSION['LAST_ACTIVITY']) &&
     (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) {
        // last request was more than 30 minutes ago
        session_unset();     // unset $_SESSION variable for the run-time
        session_destroy();   // destroy session data in storage
    }
    $_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp

              OR

    if (!isset($_SESSION['CREATED'])) {
        $_SESSION['CREATED'] = time();
    } else if (time() - $_SESSION['CREATED'] > 1800) {
        // session started more than 30 minutes ago
        session_regenerate_id(true);  
    // change session ID for the current session and invalidate old session ID
        $_SESSION['CREATED'] = time();  // update creation time
    }

    Note that session.gc_maxlifetime should be at least equal to the
     lifetime of this custom expiration handler 1800 in this example.

    PHP INTERFACES


    Class inheritanceenables you to describe a parent-child relationship
    between classes. For example, you might have a base class
     Shapefrom which both Squareand Circlederive. However,
     you might often want to add additional “interfaces” to classes,
     basically meaning additional
     contracts to which
    the class must adhere. This is achieved in C++ by using multiple
     inheritance and deriving from two classes. PHP chose interfaces
     as an alternative to multiple inheritance, which allows you to specify
     additional contracts a class must follow. An interface is declared
    similar to a class but only includes function prototypes without
    implementation and constants. Any class that “implements”
     this interface automatically has the interface’s constants defined and,
    as the implementing class, needs to supply the function definitions for the
    interface’s function prototypes that are all abstractmethods unless you
    declare the implementing class as abstract.

    abstract class Shape {
    function setCenter($x, $y) {
    $this->x = $x;
    $this->y = $y;
    }
    abstract function draw();

    protected $x, $y;
    }
    class Square extends Shape {
    function draw()
    {
    // Here goes the code which draws the Square
    ...
    }
    }
    class Circle extends Shape {
    function draw()
    {
    // Here goes the code which draws the Circle
    ...
    }
    }
    You can see that the draw()abstract method does not
     contain any code.

    To implement an interface, use the following syntax:
    class A implements B, C, ... {
    ...
    }

    Classes that implement an interface have an instance of a relationship
     with the interface; for example, if class Aimplements interface
     myInterface, the following results in '$obj is-A myInterface'printing:

    $obj = new A();
    if ($obj instanceof myInterface) {
    print '$obj is-A myInterface';
    }

    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