<script type="text/javascript">
func1(){};
func2(){};
</script>
<body>
<a href="javascript:func1();">some text</a>
<a href="javascript:func2();">some text</a>
</body>
How do I know which link is clicked in php?
<script type="text/javascript">
func1(){};
func2(){};
</script>
<body>
<a href="javascript:func1();">some text</a>
<a href="javascript:func2();">some text</a>
</body>
How do I know which link is clicked in php?
 
    
    Php is a server-side language. If you want to let the server know that the client clicked on a link, you could make an ajax-request.
<html>
    <body>
        <script type="text/javascript">
            function callAjax(url, callback){
                var xmlhttp;
                // compatible with IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp = new XMLHttpRequest();
                xmlhttp.onreadystatechange = function(){
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
                        callback(xmlhttp.responseText);
                    }
                }
                xmlhttp.open("GET", url, true);
                xmlhttp.send();
            }
            function func(id){
                callAjax('some_file.php?id=func'+id, function(res){alert(res);})
            };
        </script>
        <a href="javascript:func(1);">some text</a>
        <a href="javascript:func(2);">some text</a>
    </body>
</html>
some_file.php:
<?php
    $id = @$_GET['id'];
    if (!isset($id))
        $id = "";
    echo "You clicked on link " . htmlspecialchars($id, ENT_QUOTES, 'UTF-8') . ".";
?>
