wepnop Posted March 17, 2011 Share Posted March 17, 2011 function conectar_bd($nombre_bd=$reg->getConf("Nombre bd"), $host=$reg->getConf("Host bd"), $usuario=$reg->getConf("Usuario bd") ) { Whats wrong with this code? it dont work. Link to comment https://forums.phpfreaks.com/topic/230905-invalid-function-syntax/ Share on other sites More sharing options...
WriteGreatCode Posted March 17, 2011 Share Posted March 17, 2011 You should post what errors you get when you go to run your code. Link to comment https://forums.phpfreaks.com/topic/230905-invalid-function-syntax/#findComment-1188603 Share on other sites More sharing options...
wepnop Posted March 17, 2011 Author Share Posted March 17, 2011 ( ! ) Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\lib\bd.php on line 15 Call Stack # Time Memory Function Location 1 0.0017 375096 {main}( ) ..\wep.php:0 2 0.0031 380792 include( 'C:\wamp\www\lib\lib_vago.php' ) ..\wep.php:8 Link to comment https://forums.phpfreaks.com/topic/230905-invalid-function-syntax/#findComment-1188606 Share on other sites More sharing options...
wepnop Posted March 18, 2011 Author Share Posted March 18, 2011 ( ! ) Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\lib\bd.php on line 15 Call Stack # Time Memory Function Location 1 0.0017 375096 {main}( ) ..\wep.php:0 2 0.0031 380792 include( 'C:\wamp\www\lib\lib_vago.php' ) ..\wep.php:8 ¿anybody? maybe the problem is that function arguments cant have a function call as default value... Link to comment https://forums.phpfreaks.com/topic/230905-invalid-function-syntax/#findComment-1189049 Share on other sites More sharing options...
salathe Posted March 18, 2011 Share Posted March 18, 2011 Default values for function parameters cannot be function calls. If you need them to be dynamic, do something like: function conectar_bd($nombre_bd = NULL, $host = NULL, $usuario = NULL) { if ($nombre_bd === NULL) { $nombre_db = $reg->getConf("Nombre bd"); } // Repeat for other parameters } Link to comment https://forums.phpfreaks.com/topic/230905-invalid-function-syntax/#findComment-1189120 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.