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

Results 1 to 8 of 8
  1.     
    #1
    Member

    Default Anyone Who Knows PHP Programing

    I like to use a php function to switch between ON and OFF automatically upon the call.
    Of course something simple like

    $condition="OFF";
    switch ($condition) {
    case "OFF" :
    $condition="ON";
    break;
    case "ON" :
    $condition="OFF";
    break;
    }

    this always returns ON but that is not what I need. How can I make it so that it remember the previous setting of $condition and act accordingly so it alternate between ON/Off automatically upon the call to the function?

    Thanks
    Tigger Reviewed by Tigger on . Anyone Who Knows PHP Programing I like to use a php function to switch between ON and OFF automatically upon the call. Of course something simple like $condition="OFF"; switch ($condition) { case "OFF" : $condition="ON"; break; case "ON" : $condition="OFF"; Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    ExpresShare.com
    it's not the proper section to post such a thread just PM a mod to move it to its proper section.
    anyway you need to check before putting off into $condition the first time if it's set or not.
    if it's not set the put off in it else(it already has a value) then nothing to do.

  4.     
    #3
    Member
    that is a good idea; thank you dermechove.

  5.     
    #4
    mmm mmm!
    Moved to development area
    HATERS GONNA probably bring up some valid points considering I am an ignorant little twat so far up my own ass that i blame my problems on everyone and if you criticize me you're automatically wrong.

  6.     
    #5
    Member
    Website's:
    sborg.us
    Tried using single quotes?

    Strings give a hell lot of trouble when used in switch-case statements. Try

    PHP Code: 
    $condition="OFF";
     
    switch (
    $condition) {
         case 
    'OFF' :
                     
    $condition="ON";
                     break;
         case 
    'ON' :
                     
    $condition="OFF";
                     break;

    If this doesn't work, Then check it via ASCII values(or equivalent).

    I hope that helps.

  7.     
    #6
    Member
    you need to store the $condition to session, cookie or database
    and the initial value should be retrived from there, it is hard coded in your script...

  8.     
    #7
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    PHP Code: 

    session_start
    ();

    $status = isset($_SESSION['status']) ? $_SESSION['status'] : "OFF";

    switch(
    $status)
    {
        case 
    "ON":
             
    $status $_SESSION['status'] = "OFF";
        break;
        case 
    "OFF":
             
    $status $_SESSION['status'] = "ON";
        break;

    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


  9.     
    #8
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    Quote Originally Posted by V3g3t4 View Post
    Tried using single quotes?
    This dies not make a difference in PHP, single quotes are used for escape chars
    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


Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Programing services
    By dropboks in forum Completed Transactions
    Replies: 0
    Last Post: 11th Mar 2012, 08:16 PM
  2. what programing language needed to code a bot
    By YOUSEFN in forum General Discussion
    Replies: 1
    Last Post: 25th Jan 2012, 04:16 PM
  3. Some help need in Java programing
    By bapi21 in forum Web Development Area
    Replies: 1
    Last Post: 10th Jul 2011, 01:08 PM
  4. TCP / Ip programing ?
    By CatchItBaby in forum Web Development Area
    Replies: 2
    Last Post: 8th Jul 2010, 02:38 PM

Tags for this Thread

BE SOCIAL