I have the php code for sql query
<? $server = "127.0.0.1"; $username = "root"; $password = "1"; $link= connecttodb($server,$username,$password); function connecttodb($server,$username,$password) { $rez=fopen("test.txt","ab"); if ($link=mysql_connect ("$server","$username","$password",TRUE)) { fwrite($rez,"".$server." \r\n"); echo "Connected successfully to >> " .$server ; $result = mysql_query('SHOW DATABASES'); echo "<br>"; while ($row = mysql_fetch_array($result)) { var_dump ($row); } } } ini_set('max_execution_time', 10); return $link; ?>
this code print my database name on the browser how I can save the database name into text file
Connected successfully to >> 127.0.0.1 array(2) { [0]=> string(18) "information_schema" ["Database"]=> string(18) "information_schema" } array(2) { [0]=> string(2) "db" ["Database"]=> string(2) "db" } array(2) { [0]=> string(5) "mysql" ["Database"]=> string(5) "mysql" } array(2) { [0]=> string(10) "phpmyadmin" ["Database"]=> string(10) "phpmyadmin" } array(2) { [0]=> string(4) "test" ["Database"]=> string(4) "test" }
var_dump() displays values along with data types as output. print_r() displays only value as output. It does not have any return type. It will return a value that is in string format.
@JMTyler var_export returns a parsable string—essentially PHP code—while var_dump provides a raw dump of the data. So, for example, if you call var_dump on an integer with the value of 1, it would print int(1) while var_export just prints out 1 .
It's too simple. The var_dump() function displays structured information about variables/expressions including its type and value. Whereas The print_r() displays information about a variable in a way that's readable by humans. Example: Say we have got the following array and we want to display its contents.
The var_dump equivalent in JavaScript? Simply, there isn't one. Prints an interactive listing of all properties of the object. This looks identical to the view that you would see in the DOM tab.
You can use the output buffering functions to capture output and write it to a file.
ob_flush(); ob_start(); while ($row = mysql_fetch_assoc($result)) { var_dump($row); } file_put_contents("dump.txt", ob_get_flush());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With