Activity Stream
48,167 MEMBERS
61009 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 10 of 10
  1.     
    #1
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com

    Default A small tip in PHP

    Thought i would share a small tip with you about php that not many people know.

    Create a file called config.php

    and in that file place the following.

    PHP Code: 
    return array(
        
    'db' => array(
            
    'host' => 'litewarez.com',
            
    'user' => 'usr'
            
    //ETC
        
    ),
    ); 
    Then when you need your config just go

    PHP Code: 
    $config = include 'config.php';
    echo 
    $config['db']['host']; // litewarez.com 
    I bet you never knew that
    litewarez Reviewed by litewarez on . A small tip in PHP Thought i would share a small tip with you about php that not many people know. Create a file called config.php and in that file place the following. return array( 'db' => array( 'host' => 'litewarez.com', Rating: 5
    Join Litewarez.net today and become apart of the community.
    Unique | Clean | Advanced (All with you in mind)
    Downloads | Webmasters


    Notifications,Forum,Chat,Community all at Litewarez Webmasters


  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    Rapidleech.com FullMaza.com WarezOcean.com MediaFireForum.com
    Nah i knew that.
    btw thanks for the tip. Starters will surely take benefit from this tip.

  4.     
    #3
    Respected Developer
    Website's:
    wrzc.org
    I used it before. Here's one pratical example from php.net I based something on a while back.

    PHP Code: 
    <?php
    //EXAMPLE  of Multi-Dimentional Array where as an array's keys are an array itself.
    //It's so easy to create one like this.

    $movie_to_watch = array ('Action'=>
              array(
    'Kanu Reeves' => 'Matrix Reloaded',
                          
    'Pearce Brosnan' => 'Die Another Day',
                          
    'Tom Cruz' => 'Mission Impossible',
                          
    'Jason Statham' => 'Crank',
                          
    'Danzel Washington' => 'Man on Fire'),
                    
    'Comedy' =>
                    array (
    'Charlie Chaplin' => 'City Lights',
                           
    'Jim Carrey'    => 'Cable Guy',
                           
    'Rowan Atkinson' => 'The Ultimate Disaster'));
    $type_wanted 'Action'//You may switch type from Action to Comedy.
    $hero_wanted 'Pearce Brosnan'// You may switch hero from Pearce Brosnan to Jim Carrey.

    print ("$hero_wanted 's  $type_wanted movie is " $movie_to_watch[$type_wanted][$hero_wanted].".");
    // produces browser output as under:
    // Pearce Brosnan 's Action movie is Die Another Day.
    ?>
    As you can see instead of having just the 'db' like Litewarez has you can expand it and have more like 'Action' 'Comedy' and 'Drama' etc. Really useful.
    Tutorial How to SEO your Warez Site a guide to help you increase your organic traffic

    Huge list of Warez Sites and free Multiposter Templates

  5.     
    #4
    Member
    Nice tip mate I didn't know this and it is certainly going to be helpful.
    A life spent making mistakes is not only more honorable, but more useful than a life spent doing nothing. ? George Bernard Shaw
    ?
    Designer. Check my designs here.

  6.     
    #5
    Member
    Website's:
    LulzIMG.com chtbx.com RapidPremium.Net ReleaseLeech.com RLSLeech.com NinjaRobotPirateZombieNazi.com
    Thanks for this. I knew about it too but still needed a good example of implementation.

  7.     
    #6
    Banned
    Website's:
    sbanime.com

    Default How to get PR1?

    Well,
    My site is1 month oldnow today and its 640K rank on alexa...

    Hmm...I would like to know when willit be pr1

  8.     
    #7
    Member
    Quote Originally Posted by Mr Happy View Post
    I used it before. Here's one pratical example from php.net I based something on a while back.

    PHP Code: 
    <?php
    //EXAMPLE  of Multi-Dimentional Array where as an array's keys are an array itself.
    //It's so easy to create one like this.

    $movie_to_watch = array ('Action'=>
              array(
    'Kanu Reeves' => 'Matrix Reloaded',
                          
    'Pearce Brosnan' => 'Die Another Day',
                          
    'Tom Cruz' => 'Mission Impossible',
                          
    'Jason Statham' => 'Crank',
                          
    'Danzel Washington' => 'Man on Fire'),
                    
    'Comedy' =>
                    array (
    'Charlie Chaplin' => 'City Lights',
                           
    'Jim Carrey'    => 'Cable Guy',
                           
    'Rowan Atkinson' => 'The Ultimate Disaster'));
    $type_wanted 'Action'//You may switch type from Action to Comedy.
    $hero_wanted 'Pearce Brosnan'// You may switch hero from Pearce Brosnan to Jim Carrey.

    print ("$hero_wanted 's  $type_wanted movie is " $movie_to_watch[$type_wanted][$hero_wanted].".");
    // produces browser output as under:
    // Pearce Brosnan 's Action movie is Die Another Day.
    ?>
    As you can see instead of having just the 'db' like Litewarez has you can expand it and have more like 'Action' 'Comedy' and 'Drama' etc. Really useful.
    Thanks, but does this example explains multi dimensional array?

    I was guessing what litewarez was doing was having these arrays written in a "return" form and could be retrieved with a variable.

  9.     
    #8
    Respected Developer
    Website's:
    PlatinumW.org NexusDDL.com HD-United.org CheckLinks.org FLVD.org
    Wow php is full of surprises

  10.     
    #9
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    Yea the tip is creating a php file that returns an array you can then use $variable = include 'some file.php';

    And yea this is a multidimensional array lol
    Join Litewarez.net today and become apart of the community.
    Unique | Clean | Advanced (All with you in mind)
    Downloads | Webmasters


    Notifications,Forum,Chat,Community all at Litewarez Webmasters


  11.     
    #10
    (╯?□?)╯︵ ┻━┻
    Website's:
    Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.com
    Returning inclusions can be useful sometimes but in the case of a config file I am unsure.

    I'd definately consider it for some kind of array which, for some reason, I want to constantly name differently.
    Projects:
    WCDDL - The Professional DDL Script
    Top Secret Project: In Development - ZOMG
    ImgTrack - Never Have Dead Images Again!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. OS for a small VPS
    By RNBxBeatz in forum Server Management
    Replies: 11
    Last Post: 31st Aug 2011, 03:19 AM
  2. Need Small help with a Small JS code
    By Netguy in forum Web Development Area
    Replies: 2
    Last Post: 5th Nov 2010, 10:08 AM
  3. Small Bug?
    By DeLeTeD in forum Feedback and Suggestions
    Replies: 8
    Last Post: 9th Oct 2010, 08:16 AM
  4. What's with the small i's?
    By Gempis in forum General Discussion
    Replies: 14
    Last Post: 30th Jun 2010, 06:05 PM
  5. Small GFX Help
    By Cooper in forum Community Cooperative
    Replies: 0
    Last Post: 19th Apr 2010, 09:52 PM
BE SOCIAL