Re: [PHP-DEV] Function proposal: varset

2011-04-27 Thread Mark
Any idea on how to progress with this idea? I certainly would like to see it in PHP 5.4 but i don't have the knowledge nor time to figure out the php internals (in C...) On Sat, Apr 23, 2011 at 4:04 AM, Ben Schmidt mail_ben_schm...@yahoo.com.auwrote: yeah you are right, passing arguments by

Re: [PHP-DEV] Function proposal: varset

2011-04-22 Thread Ben Schmidt
yeah you are right, passing arguments by reference doesn't trigger the notice, but I'm not sure that it is applicable in our case. Yeah, it wouldn't help. For instance, 42 or default can't be passed by reference, so you couldn't actually provide a default value to coalesce() if you implemented

RE: [PHP-DEV] Function proposal: varset

2011-04-21 Thread Jonathan Bond-Caron
On Wed Apr 20 04:41 PM, D. Dante Lorenso wrote: My proposal was called filled since it was the opposite of empty which already existed. I extended the function to return the first non-empty value or null if all values evaluated as empty. You could use the function like this: $x =

Re: [PHP-DEV] Function proposal: varset

2011-04-21 Thread Brian Moon
I proposed something similar over 5 years ago. It ain't gonna happen because PHP language can't support it. It supports it. Several functions allow you to pass in variables that are not set and don't throw an error. Not sure what you are talking about. Brian. -- PHP Internals - PHP Runtime

Re: [PHP-DEV] Function proposal: varset

2011-04-21 Thread Ferenc Kovacs
On Thu, Apr 21, 2011 at 8:37 PM, Brian Moon br...@moonspot.net wrote: I proposed something similar over 5 years ago. It ain't gonna happen because PHP language can't support it. It supports it. Several functions allow you to pass in variables that are not set and don't throw an error. Not

Re: [PHP-DEV] Function proposal: varset

2011-04-21 Thread Brian Moon
which one? I guess that you are talking about the language constructs like isset and empty. they aren't functions. settype() for one. Brian. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Function proposal: varset

2011-04-21 Thread Ferenc Kovacs
On Fri, Apr 22, 2011 at 12:07 AM, Brian Moon br...@moonspot.net wrote: which one? I guess that you are talking about the language constructs like isset and empty. they aren't functions. settype() for one. Brian. yeah you are right, passing arguments by reference doesn't trigger the

[PHP-DEV] Function proposal: varset

2011-04-20 Thread Mark
Hi, This proposal is for the often called line like this: $var = isset($_GET['var']) ? $_GET['var'] : ''; Only a shorter and imho a cleaner solution to get the same: $var = varset($_GET['var']); The implementation for this in PHP code is this: # Arg 1 = the variable to check for existence #

Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Alain Williams
On Wed, Apr 20, 2011 at 04:55:00PM +0200, Mark wrote: Hi, This proposal is for the often called line like this: $var = isset($_GET['var']) ? $_GET['var'] : ''; Only a shorter and imho a cleaner solution to get the same: $var = varset($_GET['var']); It should be called var_set() - better

Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Mark
On Wed, Apr 20, 2011 at 5:12 PM, Alain Williams a...@phcomp.co.uk wrote: On Wed, Apr 20, 2011 at 04:55:00PM +0200, Mark wrote: Hi, This proposal is for the often called line like this: $var = isset($_GET['var']) ? $_GET['var'] : ''; Only a shorter and imho a cleaner solution to get

Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Alain Williams
On Wed, Apr 20, 2011 at 05:19:36PM +0200, Mark wrote: If is is a language element (like isset()) then you can avoid this problem. Could you explain that a bit more? It looks like a function but is not: http://uk3.php.net/manual/en/function.isset.php It might be nice to extend

RE: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Jonathan Bond-Caron
On Wed Apr 20 10:55 AM, Mark wrote: function varset($arr, $key, $default = '') { return (isset($arr[$key]) ? $arr[$key] : $default); } where the call would be: $var = varset($_GET, 'var'); I personally like both ways... My proposal is to make this function a core php function in PHP

Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Brian Moon
It might be nice to extend it such that if the 1st argument is a list then the first in the list which is set is returned, eg: $var = var_set(($_GET['var'], $_POST['var']), 'default'); If that is the usage, I would suggest coalesce() to be consistent with the same concept in SQL. And

Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Alain Williams
On Wed, Apr 20, 2011 at 11:06:47AM -0500, Brian Moon wrote: It might be nice to extend it such that if the 1st argument is a list then the first in the list which is set is returned, eg: $var = var_set(($_GET['var'], $_POST['var']), 'default'); If that is the usage, I would suggest

Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Hannes Landeholm
This discussion is equivalent to the one that we just had. Read the thread [PHP-DEV] Implicit isset/isempty check on short-ternary operator. Also the $var = var_set($_GET['var'], $_POST['var'], 'default'); syntax you propose would be equivalent to (as per previous discussion): $var =

Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Ferenc Kovacs
On Wed, Apr 20, 2011 at 7:14 PM, Hannes Landeholm landeh...@gmail.comwrote: This discussion is equivalent to the one that we just had. Read the thread [PHP-DEV] Implicit isset/isempty check on short-ternary operator. except that it wouldn't bring new syntax. ps: please don't top post if

Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread Mark
On Wed, Apr 20, 2011 at 6:00 PM, Jonathan Bond-Caron jbo...@openmv.comwrote: On Wed Apr 20 10:55 AM, Mark wrote: function varset($arr, $key, $default = '') { return (isset($arr[$key]) ? $arr[$key] : $default); } where the call would be: $var = varset($_GET, 'var'); I personally

Re: [PHP-DEV] Function proposal: varset

2011-04-20 Thread D. Dante Lorenso
On 4/20/11 9:55 AM, Mark wrote: Hi, This proposal is for the often called line like this: $var = isset($_GET['var']) ? $_GET['var'] : ''; Only a shorter and imho a cleaner solution to get the same: $var = varset($_GET['var']); The implementation for this in PHP code is this: # Arg 1 = the

Re: [PHP-DEV] Function proposal

2005-05-17 Thread Ante Drnasin
Thanx guys for the advices Respect... Ante Marcus Boerger wrote: Hello AnteD, Friday, May 13, 2005, 1:29:36 PM, you wrote: Hi guys... Yes I know that this is a small function and yes I know it can be copy-paste with every new project you do but from the first day I've been using

[PHP-DEV] Function proposal

2005-05-16 Thread AnteD
Hi guys... Yes I know that this is a small function and yes I know it can be copy-paste with every new project you do but from the first day I've been using PHP until today this function follows me everywhere and I now that everyone is using it one way or the other for debugging.. the

Re: [PHP-DEV] Function proposal

2005-05-16 Thread Benj Carson
Hmm, it's no GOTO, but oddly enough we have virtually exactly the same function and use it everywhere too. The only differences are we call ours pre_r() and we add the following check against php_sapi_name() so that the function behaves sanely when called from the cli: function pre_r($mixed,

Re: [PHP-DEV] Function proposal

2005-05-16 Thread Sean Coates
AnteD wrote: Yes I know that this is a small function and yes I know it can be copy-paste with every new project you do but from the first day I've been using PHP until today this function follows me everywhere and I now that everyone is using it one way or the other for debugging.. ... The

Fwd: Re: [PHP-DEV] Function proposal

2005-05-16 Thread Petar Nedyalkov
On Friday 13 May 2005 14:29, AnteD wrote: Hi guys... Yes I know that this is a small function and yes I know it can be copy-paste with every new project you do but from the first day I've been using PHP until today this function follows me everywhere and I now that everyone is using it one

Re: [PHP-DEV] Function proposal

2005-05-16 Thread Derick Rethans
On Mon, 16 May 2005, Sean Coates wrote: AnteD wrote: Yes I know that this is a small function and yes I know it can be copy-paste with every new project you do but from the first day I've been using PHP until today this function follows me everywhere and I now that everyone is using it

Re: [PHP-DEV] Function proposal

2005-05-16 Thread Sara Golemon
Yes I know that this is a small function and yes I know it can be copy-paste with every new project you do but from the first day I've been using PHP until today this function follows me everywhere and I now that everyone is using it one way or the other for debugging.. ...

Re: [PHP-DEV] Function proposal

2005-05-16 Thread Marcus Boerger
Hello AnteD, Friday, May 13, 2005, 1:29:36 PM, you wrote: Hi guys... Yes I know that this is a small function and yes I know it can be copy-paste with every new project you do but from the first day I've been using PHP until today this function follows me everywhere and I now that

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-03-15 Thread Frédéric LECOINTRE
Hello, yes ? no ? perhaps ? something ? :-) - Original Message - From: Frédéric LECOINTRE [EMAIL PROTECTED] To: internals@lists.php.net Sent: Friday, February 25, 2005 5:12 PM Subject: Re: [PHP-DEV] function proposal - php_check_syntax_string | Hello, | | After tests, I did'nt note

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-25 Thread Frédéric LECOINTRE
PROTECTED] Cc: internals@lists.php.net Sent: Tuesday, February 22, 2005 3:20 PM Subject: Re: [PHP-DEV] function proposal - php_check_syntax_string | Hello all, | | thanks John for help | | so here, http://php-dev.burnweb.net. | there's new diff to avoid unexpected end of script on fatal error. | (add

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-22 Thread Frédéric LECOINTRE
Coggeshall [EMAIL PROTECTED] To: Marcus Boerger [EMAIL PROTECTED] Cc: Frédéric LECOINTRE [EMAIL PROTECTED]; internals@lists.php.net Sent: Monday, February 21, 2005 11:45 PM Subject: Re: [PHP-DEV] function proposal - php_check_syntax_string | On Mon, 2005-02-21 at 17:07, Marcus Boerger wrote: | I

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-21 Thread Frédéric LECOINTRE
Hello Marcus, | have you experimented with php_check_syntax() and temporairy streams? tell me if i'm wrong. I think it could be possible to use php_lint_script and do compiler read variable instead of file - set zend_file_handle-type = ZEND_HANDLE_STREAM - define two functions for reader and

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-21 Thread Marcus Boerger
Hello Frédéric, Monday, February 21, 2005, 1:56:01 PM, you wrote: Hello Marcus, | have you experimented with php_check_syntax() and temporairy streams? tell me if i'm wrong. I think it could be possible to use php_lint_script and do compiler read variable instead of file - set

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-20 Thread Marcus Boerger
:17 PM Subject: Re: [PHP-DEV] function proposal - php_check_syntax_string | Hi Fred, | | this patch doesn't just check wether the string has the right syntax but | also compiles it and registers it's functions and classes in the relevant | tables. | | $ sapi/cli/php -r

Re[2]: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-20 Thread val khokhlov
Hello Marcus, Sunday, February 20, 2005, 6:32:57 AM, you wrote: MB what happend to defines (when redefining) define() is called at run-time, as far as i saw, so there should be no problems with it MB and what happens to __autoload()? well, i never used it myself, so i've never

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-20 Thread Marcus Boerger
Hello val, Sunday, February 20, 2005, 5:59:21 PM, you wrote: Hello Marcus, Sunday, February 20, 2005, 6:32:57 AM, you wrote: MB what happend to defines (when redefining) define() is called at run-time, as far as i saw, so there should be no problems with it MB and what happens to

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-20 Thread Frédéric LECOINTRE
Boerger [EMAIL PROTECTED] To: val khokhlov [EMAIL PROTECTED] Cc: internals@lists.php.net Sent: Sunday, February 20, 2005 6:05 PM Subject: Re: [PHP-DEV] function proposal - php_check_syntax_string | Hello val, | | Sunday, February 20, 2005, 5:59:21 PM, you wrote: | | Hello Marcus, | | Sunday

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-20 Thread Marcus Boerger
PHP_Parser would be a reasonable solution fred - Original Message - From: Marcus Boerger [EMAIL PROTECTED] To: val khokhlov [EMAIL PROTECTED] Cc: internals@lists.php.net Sent: Sunday, February 20, 2005 6:05 PM Subject: Re: [PHP-DEV] function proposal - php_check_syntax_string | Hello

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-19 Thread Frédéric LECOINTRE
in Smarty_Compiler.class.php#144-164 with limitations) fred - Original Message - From: Johannes Schlueter [EMAIL PROTECTED] To: internals@lists.php.net Sent: Friday, February 18, 2005 1:17 PM Subject: Re: [PHP-DEV] function proposal - php_check_syntax_string | Hi Fred, | | this patch doesn't just check

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-19 Thread Alan Knowles
I guess swapping out the compiler and executer globals before /after the compile call wont work? egs = executor_globals cgs = compiler_globals compile_string / file etc. efree(executor_globals); efree(compiler_globals); executor_globals = egs; compiler_globals = cgs; obviously if this is the

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-18 Thread Marcus Boerger
Hello Frédéric, do you have some c code you can post here as a .txt attachment or as a link? regards marcus Friday, February 18, 2005, 4:41:06 AM, you wrote: hi all, to check syntax of pieces of code and to avoid wild regular expressions, i wrote this: proto bool

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-18 Thread Frédéric LECOINTRE
Hello Marcus, Based on 5.0.3 source distribution, inspired of parsekit_compile_string fred - Original Message - From: Marcus Boerger [EMAIL PROTECTED] To: Frédéric LECOINTRE [EMAIL PROTECTED] Cc: internals@lists.php.net Sent: Friday, February 18, 2005 9:25 AM Subject: Re: [PHP-DEV

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-18 Thread Johannes Schlueter
-DEV] function proposal - php_check_syntax_string | Hello Frdric, | | do you have some c code you can post here as a .txt attachment or as a link? | | regards | marcus | | Friday, February 18, 2005, 4:41:06 AM, you wrote: | | hi all, | | to check syntax of pieces of code

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-18 Thread Frédéric LECOINTRE
(or something else) instead of removing the introduced code? fred - Original Message - From: Johannes Schlueter [EMAIL PROTECTED] To: internals@lists.php.net Sent: Friday, February 18, 2005 1:17 PM Subject: Re: [PHP-DEV] function proposal - php_check_syntax_string | Hi Fred

Re[2]: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-18 Thread val khokhlov
Hello Johannes, Friday, February 18, 2005, 2:17:12 PM, you wrote: JS this patch doesn't just check wether the string has the right syntax but JS also compiles it and registers it's functions and classes in the relevant JS tables. well, they need to add this code to avoid it:

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-18 Thread Andi Gutmans
in zend_language_scanner.c (or something else) instead of removing the introduced code? fred - Original Message - From: Johannes Schlueter [EMAIL PROTECTED] To: internals@lists.php.net Sent: Friday, February 18, 2005 1:17 PM Subject: Re: [PHP-DEV] function proposal - php_check_syntax_string | Hi Fred

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-18 Thread Johannes Schlueter
Hi, Frdric LECOINTRE wrote: oups ... well. php_check_syntax works fine with zend_compile_file. so what's the No, it doesn't work fine, too :-) http://bugs.php.net/bug.php?id=27406 But I didn't know the problem either when reading your patch where I stumbled over the compile_string() call.

Re: [PHP-DEV] function proposal - php_check_syntax_string

2005-02-18 Thread Sara Golemon
Is there possibilty to run syntax check only with compil_string in zend_language_scanner.c (or something else) instead of removing the introduced code? No. At least I don't know a how (but I don't know everything about the engine) The only thing I currently can think of is using the

[PHP-DEV] function proposal - php_check_syntax_string

2005-02-17 Thread Frédéric LECOINTRE
hi all, to check syntax of pieces of code and to avoid wild regular expressions, i wrote this: proto bool php_check_syntax_string(string string [, $error_message]) like php_check_syntax but on string it will be useful for applications who have to store valid code like smarty, ... is it possible

Re: [PHP-DEV] Function proposal: nl2p

2004-03-07 Thread Markus Fischer
On Sun, Mar 07, 2004 at 01:07:08PM -0500, Louis-Philippe Huberdeau wrote : /* {{{ proto string nl2p(string str) Converts newlines to HTML paragraphs for standard compliance */ I'm not to judge whether this goes in or not, however using paragraphs is not more standard compliance than

Re: [PHP-DEV] Function proposal: nl2p

2004-03-07 Thread Stefan Walk
On Sun, Mar 07, 2004 at 01:07:08PM -0500, Louis-Philippe Huberdeau wrote: I wrote this very simple function (modification from nl2br actually) to convert newlines to well formatted HTML paragraphs instead of line breaks, allowing better formatting of a dynamic output. It's not the most

Re: [PHP-DEV] Function proposal: nl2p

2004-03-07 Thread Kai Schröder
On Sunday 07 March 2004 21:58, Stefan Walk wrote: On Sun, Mar 07, 2004 at 01:07:08PM -0500, Louis-Philippe Huberdeau wrote: I wrote this very simple function (modification from nl2br actually) to convert newlines to well formatted HTML paragraphs instead of line breaks, allowing better

Re: [PHP-DEV] Function proposal: nl2p

2004-03-07 Thread Sara Golemon
Intresting for users that need such functions on several places in code and in this case better as regexp in PHP itself. Why not take this ideas and put together into ext/html(format)? I agree with the statement that functions like these (and nl2br() itself) don't really belong in the PHP

[PHP-DEV] Function proposal: nl2p

2004-03-07 Thread Louis-Philippe Huberdeau
I wrote this very simple function (modification from nl2br actually) to convert newlines to well formatted HTML paragraphs instead of line breaks, allowing better formatting of a dynamic output. It's not the most perfect piece of code ever written, but it works and it can be quite useful. The