On Fri, Apr 1, 2011 at 2:07 PM, Jim Giner <jim.giner@xxxxxxxxxxxxxxxxxx>wrote: > I have this code in my php script. A simple page to test out a function > that I learned from a book I bought. > > <?php > $root = $_SERVER['DOCUMENT_ROOT']; > include($root.'/../php/inc/js/getText.js'); > ?> > > </head> > > > The include gets a function I wrote called getText and I have dumped the > source code of my webpage after I get the error and i see that the include > did in fact work. There is a function with that name. Here is the header > > <script type="text/javascript"> > function getText(e) > { > . > > . > > .} > </script> > </head> > > > In the body of my html doc built by this script I have the following lines: > > echo 'para contains: '; > echo getText("p1"); **** > echo '<br><br>'; > echo 'heaading contains: '.getText("h2"); > ?> > </body> > > > I get this output on the line containing the **** > > para contains: > Fatal error: Call to undefined function getText() in > /home/albany/public_html/players_dir/test_gettext.php on line 23 > > > As you can see my output starts out as I expect but then I get the > undefined > function message. > > What am I not doing correctly? > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > It looks like you've defined getText() as a JavaScript function, but because your call to the function is not in quotes, PHP is treating it as a PHP function. Try something like: ... echo 'heaading contains: <script>getText("h2")</script>'; ... -- Sláinte, Richard S. Crawford (richard@xxxxxxxxxxxxx) http://www.underpope.com Publisher and Editor in Chief, Daikaijuzine (http://www.daikaijuzine.com)