user63898
user63898

Reputation: 30885

How can print values form inside class function in php

I have simple php page that calls php object method like this: this is the HTML page that build the html view

$queryManager = new  QueryManager();
$result = $queryManager->GetCreatedCars($userId);
while($row = mysql_fetch_array($result))
{
...blah blah ....
}

and this is how the GetCreatedCars looks
public function GetCreatedCars($user_fb_id)
    {
        $bcon  = $this->ConnectToDb();
        $myStr = "SELECT * FROM ...blah blah .....";

            echo "$myStr <br>"; <----THIS I WANT TO PRINT TO HTML VIEW 
                $result = mysql_query($SqlStr);
        if(!$result)
            die('Could select db: ' . mysql_error());
        return $result;
    }

now i like to print to page the $myStr just for debug ,but the dosn't prints any thing i can print only what i have in the view php file where i call GetCreatedCars method

Upvotes: 0

Views: 409

Answers (2)

user827080
user827080

Reputation:

Try changing echo ...; to die(...);. This way, if the method gets called correctly, the page will "die" and show that message at the bottom.

Upvotes: 0

jjs
jjs

Reputation: 21

Are you sure your method gets called? Please post a minimal testcase. Does $this->ConnectToDb terminate the program (perhaps the method does not exist).

Upvotes: 1

Related Questions