473,573 Members | 3,117 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Syntax checking with create_function ()

Hi all,

The thing I'm doing just now uses create_function (). This works fine
provided I don't do something silly in the code I am trying to incorporate.

Is there any way I can check the syntax (like `php -l sript.php`). I know
that there is php_check_synta x() in PHP 5 but it needs a file & I'm still
on v 4.x.

I guess I could create a temporary file and try `php -l $tempfile` but
there's the complications of knowing what OS is on the machine where it's
running, also just because it has mod_php doesn't necessarily mean it has
the standalone.

I tried the code below, but it seems to only throw errors when you try to
execute the function which got created.

TIA,

C.

function lister_check_er rors($errno, $errstr, $errfile, $errline)
{
global $lister_embed_e rrors;
$errdesc=array( FATAL=>'FATAL', ERROR=>'ERROR', WARNING=>'WARNI NG');
$errtype=$errde sc[$errno];
if ($errtype=='') {
$errtype="UNKNO WN";
}
$lister_embed_e rrors="$errtype [$errno]: $errstr<br />\n&nbsp; in line
$errline";
}
function lister_check_sy ntax($code,$par ams)
{
global $lister_embed_e rrors;
$lister_embed_e rrors='';
$errhandler=set _error_handler( 'lister_check_e rrors');
if ($errhandler=== false) {
return("set_err or_handler() returned false");
}
// this doesn't detect the errors - you need to run the function
// to prove it! But this may modify the thing we are trying to list
$fn=create_func tion($params,$c ode);
set_error_handl er($errhandler) ;
return($lister_ embed_errors);
}

Jul 17 '05 #1
1 1794
Colin McKinnon wrote:

I tried the code below, but it seems to only throw errors when you try to
execute the function which got created.


Actually, it is throwing the errors - just not the way I thot it would. Back
to the drawing board.

C.
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2584
by: TheKeith | last post by:
Hi, I'm just learning php now for the first time and I'm having a little trouble understanding something. In the following example: ------------------------------------------------------------------------ <?php function test ($thenum) {
3
2632
by: Ian.H | last post by:
Hi all, I'm trying to write a PHP colour parser and after various attempts, something, somewhere trips it over. Some details: String to parse: $origString = '^1foo^5bar';
2
2047
by: George Sakkis | last post by:
I downloaded the latest Komodo (3.1) and configured it for python 2.4 so that it doesn't show decorators and genexps as syntax errors, but background syntax checking doesn't seem to work at all for python 2.4. Even for correct files, it shows a "Syntax checking error: Error checking syntax: retval = 128, stderr=" alert. For python 2.3 it works...
4
3422
by: nonzero | last post by:
I was hoping someone could explain the Syntax of the second argument of the bind() function. bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)); .....................(struct sockaddr *)&my_addr.................................... I understand that it is converting the structure at &my_addr to a structure type sockaddr. ...
1
3297
by: Karim Nassar | last post by:
I am writing functions and I find it curious that CREATE FUNCTION does not do syntax checking. Example: test=# CREATE FUNCTION foo(INTEGER) RETURNS BOOLEAN test-# AS 'this is total crap' LANGUAGE plpgsql; CREATE FUNCTION test=# select foo(1); ERROR: syntax error at or near "this"
21
2319
by: Dmitry Anikin | last post by:
I mean, it's very convenient when default parameters can be in any position, like def a_func(x = 2, y = 1, z): ... (that defaults must go last is really a C++ quirk which is needed for overload resolution, isn't it?) and when calling, just omit parameter when you want to use defaults: a_func(, , 3)
0
1183
by: Dima Vidmich | last post by:
Recently I think about some sort of safe includes which will not fail if parse error happened. And many different sourses said that this is imposible without some non standard modules and without calling "perl -l" I made some investigation and found this way: function check_syntax($filename) { // load file
8
1835
by: lawrence k | last post by:
Just noticed this for the first time: http://us2.php.net/manual/en/function.create-function.php Anyone know if PHP supports enclosures, like Javascript or Ruby? I've always assumed PHP lacked these. If I create a function with object instances, will the instances retain their state if the function definition is stored in a variable?
4
10581
by: FM | last post by:
Hi there: My question is about checking my sql-syntax against DB2UDB V9 throug JDBC 2.0 Is there a way to check my syntax,for example "select * from T1"? Thank you for your help. Regards,
0
7778
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7687
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5585
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5290
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3731
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2203
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1300
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.