Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

echo variables from a class

Tags:

php

echo

class

I need to know how I can echo $host from the following class:

class JConfig {

    public $host = 'localhost';

}

any ideas?

Thanks!

like image 391
Maarten Hartman Avatar asked May 12 '26 19:05

Maarten Hartman


1 Answers

$jc = new JConfig();
echo $jc->host;

You may want to look into static variables though.

like image 86
bcmcfc Avatar answered May 14 '26 11:05

bcmcfc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!