What are the different ways to embed a PHP script on other websites?

To embed a PHP script on other websites, you can use iframe tags, PHP include function, or AJAX requests. These methods allow you to include the PHP script seamlessly within the HTML of another website.

<?php
// Method 1: Using iframe
echo '<iframe src="http://www.example.com/script.php"></iframe>';

// Method 2: Using PHP include
include 'http://www.example.com/script.php';

// Method 3: Using AJAX request
echo '<div id="result"></div>';
echo '<script>
    var xhr = new XMLHttpRequest();
    xhr.open("GET", "http://www.example.com/script.php", true);
    xhr.onload = function() {
        document.getElementById("result").innerHTML = xhr.responseText;
    };
    xhr.send();
</script>';