coding azra - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of coding azra.php

  1. <!DOCTYPE html>
  2. <html>
  3.   <head>
  4.     <title>Gambar Anjing Bergerak</title>
  5.     <style>
  6.       #anjing {
  7.         position: absolute;
  8.         left: 0;
  9.         top: 0;
  10.       }
  11.     </style>
  12.   </head>
  13.   <body>
  14.     <img id="anjing" src="anjing.png" alt="Gambar Anjing">
  15.     <script>
  16.       var anjing = document.getElementById('anjing');
  17.       var posisi = 0;
  18.       var kecepatan = 5;
  19.       var arah = 1;
  20.       
  21.       function gerak() {
  22.         posisi += kecepatan * arah;
  23.         anjing.style.left = posisi + 'px';
  24.         
  25.         if (posisi >= window.innerWidth - anjing.width || posisi <= 0) {
  26.           arah = -arah;
  27.           anjing.style.transform = 'scaleX(' + arah + ')';
  28.         }
  29.       }
  30.       
  31.       setInterval(gerak, 50);
  32.     </script>
  33.   </body>
  34. </html>
  35.  
File Description
  • coding azra
  • PHP Code
  • 08 May-2023
  • 793 Bytes
You can Share it: