PHP Classes

PHP Echo Page Function and Line to HTML Div via JavaScript: Show the calling function and line with JavaScript

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 52 This week: 1All time: 10,609 This week: 560Up
Version License PHP version Categories
php__echo_page_funct 1.0MIT/X Consortium ...5PHP 5, Debug, Language
Description 

Author

This package can show the calling function and line with JavaScript.

It provides functions that can determine the name and the line of current PHP script that calls that functions.

The functions can display the function name and line using either PHP or JavaScript.

Picture of jon
Name: jon <contact>
Classes: 5 packages by
Country: New Zealand New Zealand
Age: ???
All time rank: 415017 in New Zealand New Zealand
Week rank: 411 Up4 in New Zealand New Zealand Up

Example

<?php

include('Wse2.php');

function
get_topmost_script()
{
   
$backtrace = debug_backtrace
   
(
       
defined
       
(
           
"DEBUG_BACKTRACE_IGNORE_ARGS"
       
)
        ?
DEBUG_BACKTRACE_IGNORE_ARGS
       
: FALSE
   
);
   
$top_frame = array_pop($backtrace);
    return
$top_frame['file'];
}

function
db()
{
   
$var = '<script>$("#console").append(\'<hr><p class="console_scriptname">& script = ';
   
$string = str_replace('\\', '\\\\', get_topmost_script());
   
$var.= $string;
   
$var.= '</p>&nbsp;&nbsp;<p class="console_semicolon">::::</p>&nbsp;&nbsp;<p class="console_function">& function = ';
   
$var.= debug_backtrace()[1]['function'];
   
$var.= '</p>&nbsp;&nbsp;<p class="console_semicolon">::::</p>&nbsp;&nbsp;<p class="console_line">& line = ';
   
$var.= debug_backtrace()[0]['line'];
   
$var.= '</p><hr>\');</script>';
   
   
/** whitespace eliminator used to get rid of whitespace so that javascript script can echo properly **/
   
echo Wse2($var);
}

function
parent_function_name()
{
   
db();
}

?>
<html>

    <head>
   
        <link href="stylesheet.css" rel="stylesheet">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <script type="text/javascript" src="js/jquery-3.3.1.js"></script>
       
    </head>
   
    <body>
   
        <div id="console">
       
        </div>
       
        <?php
       
        parent_function_name
();
       
       
?>
</body>

</html>

















  Files folder image Files  
File Role Description
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file jquery-3.3.1.js Data Auxiliary data
Accessible without login Plain text file stylesheet.css Data Auxiliary data
Accessible without login Plain text file Wse2.php Aux. Auxiliary script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:52
This week:1
All time:10,609
This week:560Up