dotkpay Posted December 20, 2011 Share Posted December 20, 2011 Hello, Is there a way I can combine js variables in a string so I can have one variable that is equal to all of them. For example if it were php: $h = "Hello/"; $w = "World"; $hw = "$h $w"; echo $hw; //Hello World Link to comment https://forums.phpfreaks.com/topic/253536-variables-in-strings/ Share on other sites More sharing options...
trq Posted December 20, 2011 Share Posted December 20, 2011 $h = "Hello/"; $w = "World"; $hw = $h + $w; console.log($hw); //Hello World While you can define your variables starting with a $ in JavaScript, you probably shouldn't though. Link to comment https://forums.phpfreaks.com/topic/253536-variables-in-strings/#findComment-1299661 Share on other sites More sharing options...
haku Posted December 23, 2011 Share Posted December 23, 2011 Agreed. Doing so will conflict with any jQuery scripts used - and jQuery is used everywhere. Link to comment https://forums.phpfreaks.com/topic/253536-variables-in-strings/#findComment-1300956 Share on other sites More sharing options...
trq Posted December 23, 2011 Share Posted December 23, 2011 Naming variables beginning with $ won't interfere with jQuery, it would only interfere if you used $ alone like jQuery does. Link to comment https://forums.phpfreaks.com/topic/253536-variables-in-strings/#findComment-1300971 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.