how to call javascript inside php, can both of these work together, what are things we need to keep in mind, while working on these platforms ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people's questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Sweta
Yes PHP and Java script can work together. You can use both at same time. But you need validation from both code, specially PHP code.
Java script is client side language while PHP works back end so to validate PHP is more important. PHP will be running on servers fetching required information requested by Java script.
Plus PHP code can create Java script. That way it will be more dynamic and less confusing for developer. So better to use PHP code to create Java script as per requirements.
Use only JavaScript is things are only required at browser side and use PHP when you need to fetch data or pages from server.
Hope this helps.