473,545 Members | 2,291 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 1790
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
2581
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
2628
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
3421
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
3294
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
2314
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
1181
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
10573
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
7398
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
7805
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...
1
7416
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
4944
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
3449
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1878
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
1013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
701
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.