Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
Cómo reproducir MP3 desde PPHP If Else
<button onclick="playSound()">Play</button> <script> function playSound() { let src = '../../sounds/paSound.mp3'; let audio = new Audio(src); audio.play(); } </script>

Tengo el código anterior que reproduce el sonido mp3 al hacer clic en el botón Reproducir.

Lo que quiero hacer es llamar y reproducir el sonido de una declaración if else en PHP. ¿Hay una manera de hacer eso?

 if(statement==true){ //call playSound js function }

He probado el siguiente código: ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Sería mejor pasar datos a JS y luego hacer if/else.

 <script> var jsvar = <?php print $phpvar ;?> if (jsvar == x) play music </script>

o

 <?php if (): ?> <script> let src = '../../sounds/paSound.mp3'; let audio = new Audio(src); audio.play(); </script> <?php endif; ?>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!