• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Weird problem with... php

#2
[eluser]Colin Williams[/eluser]
Functions cannot be defined inside a method (at least not reliably, or for any reason). Instead of a function, write a method:

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Test extends Controller {
    
    function index()
    {    
            
        if ($this->_check_txn_id('inexistent_id') == true) echo 'The function should return true'; else echo 'The function should return false';

        echo 'This should be echoed anyway... but it\'s not.';
    }

}

function _check_txn_id($txnid)
            {
                $i = $this->db->select('id')->from('table')->where('txnid', $txnid)->get();
                return $var = ($i->num_rows() > 0) ? true : false;
            }

Better yet, have this method in a Model, since it deals with stored data


Messages In This Thread
Weird problem with... php - by El Forum - 09-26-2008, 04:39 PM
Weird problem with... php - by El Forum - 09-26-2008, 05:13 PM
Weird problem with... php - by El Forum - 09-26-2008, 06:27 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.