Guntar Posted August 25, 2010 Share Posted August 25, 2010 Gentlemen, I am straggling with the (public static function ()) I created. //below is the similar sample function I created <?php class Account{ private static $account_1=false; private static $account_2=false; private static $account_3=false; private static function set_vars(){ //this function will change class attributes (accounts) } public static function check_account(){ if(self::$account_1 && !self::$account_2){ return 4; }elseif(self::$account_1 && self::$account_3){ return 3; }else{ return 1; } } } ?> //end of Account class Here is what I am ranning into: When I call this function in any given page it works the way it was intended to work: <?php $test=Account::check_account(); //and I am able to echo the results back on the page echo $test; //and it will return one of the three numbers (1 or 3 or 4) ?> Then there are places in the code where I am calling this function to check the accounts. <?php // some processing $test=Account::check_account(); //after this function I want to check what results it returned and baset on that I want to do something else if($test==3){ send_email(); } ?> The problem I am running into is after executing the function () I don’t get any results back. It will always return (1) because it is the default. But the function did execute because the account was updated. Usually the code that does the testin is on different document and that document is being included in the page i.e.: if(isset($_POST[‘submit’])){ include_once(“../processing/check_account_status.php”); } Can you guys tell me am I doing something wrong? Link to comment https://forums.phpfreaks.com/topic/211722-can%E2%80%99t-make-the-public-%E2%80%9Cstatic-function-check_account%E2%80%9D-to-work/ Share on other sites More sharing options...
AbraCadaver Posted August 25, 2010 Share Posted August 25, 2010 You'll have to show all code that you're using. You haven't shown a real world scenario (you haven't set any vars and don't have code to do it). Also, wrap your code in the php code tags using the button. Link to comment https://forums.phpfreaks.com/topic/211722-can%E2%80%99t-make-the-public-%E2%80%9Cstatic-function-check_account%E2%80%9D-to-work/#findComment-1103657 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.