Ask coding questions

← Back to all posts
Please help me to solve this code
Doraemon420 (0)

please help to solve

i want to use all of my variables in uppercase letter by using "foreach loop" but there is showing error.

Code is down below:

<?php $db['db_host'] = "localhost"; $db['db_user'] = "root"; $db['db_pass'] = ""; $db['db_name'] = "cms"; foreach($db as $key => value){ define(strtoupper($key),value); } $connection = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); if($connection){ echo "We are connected"; } ?>
Commentshotnewtop
Vandesm14 (1223)

PHP does not work on repl.it and they are most likely not going to fix this. If you would like to use server-side code, try Expressjs: https://repl.it/languages/express

Please mark this as answered if I helped your problem 👍

Doraemon420 (0)

@Vandesm14 Actually I run this code in xampp and it's not working

Vandesm14 (1223)

@Doraemon420 Ok. Still, PHP does not work on repl.it and they are most likely not going to fix this. If you would like to use server-side code, try Expressjs: https://repl.it/languages/express