Hello .. well my question is .. which is better to use ? <?php include('config.php'); $load = "SELECT * FROM members WHERE user_name='$uusername'"; $query = mysql_query($load,$conn) ; $row = mysql_fetch_object($query); $name = $row->name; echo "Hello .. My name is $row->name"; // This ??? echo "Hello .. My name is $name"; // or this ?? ?> PHP: well i'm talking about which is faster ? better ? Thanks
I would say if you define $row->name as a variable, you may aswell use that variable. If you didn't bother defining $row->name as a variable, maybe that way would be quicker. Personally, I would define it as a variable and then use the variable. It seems more sensible to do so as you can call it something specific for later use and its a lot easier to type to re-use. I would say there isn't really a speed issue here
echo 'Hello .. My name is ' . $row->name; Is faster still. P.s. Don't use mysql_fetch_object, it's slow: http://php.net/manual/en/function.mysql-fetch-array.php Is faster. (Regardless what the notes say.)
No, mysql_fetch_array is faster, hence better. Functionality is the same but the OOP overhead is pointless. It's practically just calling mysql_fetch_array then setting the type to an (object). Dan