RE: [PHP] regex or 'tidy' script to fix broken ? tags and introspection of variables

2011-08-10 Thread Daevid Vincent
 -Original Message-
 From: Camilo Sperberg [mailto:unrea...@gmail.com]
 Sent: Tuesday, August 09, 2011 5:27 PM
 
 For the first one, it may be that zend studio does have an internal script
 to do the job. Check the general preferences tab, template stuff. 

Nope. Nothing there. Those templates are for when you create new blurbs of
code, not modifying existing code.

There is a formatter however, sadly it doesn't have an option to force these
(you'd think that would be the perfect place to do this too huh.) In fact, I
posted this here:

http://forums.zend.com/viewtopic.php?f=59t=19173#p59348

 Please note that ?= is also valid and should be replaced to ?php echo
instead.

Yeah, I don't like that style. I prefer the ?= $foo ? version. It's
shorter, cleaner and easier to read.

Many people mistakenly think that short version is going to be deprecated
away. It is not. The PHP Devs have already clarified only the ? version
is, not this one.

http://www.php.net/manual/en/ini.core.php#ini.short-open-tag

 Also the short if version 1 == 1 ? True : false should be replaced if
i'm correct.

You are not. ;-)

The Ternary operator statement would never go away. It is a standard
comparison operator in pretty much any language and would be completely
stupid of the PHP Devs to deviate that far from the norm.

http://php.net/manual/en/language.operators.comparison.php

Plus I love that operator and use it quite frequently. However, I use it
like this just for clarity:

echo your result is .((1 == 1) ? 'true' : 'false').'br';

 Second question: zend studio displays all variables used by a script by
 clicking the arrow next to te file name. 

I've used ZS for 4+ years now, and comicaly have never even used those
little down arrows next to a file. HAHAH! Good to know. Although it is a
little strange as they seem to only be where you use a = assignment. It
doesn't know about - or other instances of that variable (like if you
echo it or something). But still could prove useful.

 If you want to display it in runtime, you can: print_r($GLOBALS);

Whoa nelly! That prints out WAAY too much information ;-)

But thanks. Not sure why I didn't think of that one. Maybe because at one
time I did use it, got sensory overload from the amount of data it spews to
the page, and then blocked it out of my mind for future use. :)


ÐÆ5ÏÐ
There are only 11 types of people in this world. Those that think binary
jokes are funny, those that don't, and those that don't know binary.
--

 Sent from my iPhone 5 Beta [Confidential use only]
 
 On 09-08-2011, at 19:40, Daevid Vincent dae...@daevid.com wrote:
 
  I've inherited a bunch of code and the previous developers have done two
  things that are really bugging me and I want to clean up.
 
  [a] They use short-tag ? instead of ?php. Anyone have some good
  search/replace style Regex (ideally for ZendStudio/Eclipse) that will
run
  through all the files in the project and fix those? There are lots of
 cases
  to account for such as a space after the ? or nospace or a newline or
even
  other text (which are all valid cases).
 
  [b] The other thing they do use use register_globals in the php.ini
file.
 Is
  there a good way to see all the variables that a page uses? Something I
 can
  print at the bottom of the page on my dev box - ideally with enough
  introspection to know where that variable originated from, and then I
can
  start converting things to $_GET, $_POST,  $_SESSION, $_COOKIE, etc.
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] regex or 'tidy' script to fix broken ? tags and introspection of variables

2011-08-10 Thread Camilo Sperberg

On 10-08-2011, at 16:54, Daevid Vincent wrote:

 -Original Message-
 From: Camilo Sperberg [mailto:unrea...@gmail.com]
 Sent: Tuesday, August 09, 2011 5:27 PM
 
 For the first one, it may be that zend studio does have an internal script
 to do the job. Check the general preferences tab, template stuff. 
 
 Nope. Nothing there. Those templates are for when you create new blurbs of
 code, not modifying existing code.
 
 There is a formatter however, sadly it doesn't have an option to force these
 (you'd think that would be the perfect place to do this too huh.) In fact, I
 posted this here:
 
 http://forums.zend.com/viewtopic.php?f=59t=19173#p59348

That is sad to hear, I have never done the same thing you are now, but I 
thought it could help.

 
 Many people mistakenly think that short version is going to be deprecated
 away. It is not. The PHP Devs have already clarified only the ? version
 is, not this one.
 
 http://www.php.net/manual/en/ini.core.php#ini.short-open-tag
 

I had no idea, I thought short tags also implied short if-else, short echo and 
so on, good to know that, thanks for the clarification ;)

 
 Second question: zend studio displays all variables used by a script by
 clicking the arrow next to te file name. 
 
 I've used ZS for 4+ years now, and comicaly have never even used those
 little down arrows next to a file. HAHAH! Good to know. Although it is a
 little strange as they seem to only be where you use a = assignment. It
 doesn't know about - or other instances of that variable (like if you
 echo it or something). But still could prove useful.

Eclipse/Zend Studio is so full of options that you can miss a lot of them. 
Another downside of the little arrow thing is that it doesn't recognize arrays, 
which is obvious because arrays can only be read on runtime, well, same thing 
as objects.

 
 If you want to display it in runtime, you can: print_r($GLOBALS);
 
 Whoa nelly! That prints out WAAY too much information ;-)
 
 But thanks. Not sure why I didn't think of that one. Maybe because at one
 time I did use it, got sensory overload from the amount of data it spews to
 the page, and then blocked it out of my mind for future use. :)

Yeah I know it displays a lot of information, but I use it sometimes and it's 
the only way I know to display all variables, arrays and stuff in a neat and 
nice way. You can also install xDebug and use the included debugger in ZS, but 
sometimes using a simple print_r is faster.

Greetings :)

___
Mi blog
CHW
Mi Twitter


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] regex or 'tidy' script to fix broken ? tags and introspection of variables

2011-08-09 Thread Daevid Vincent
I've inherited a bunch of code and the previous developers have done two
things that are really bugging me and I want to clean up.
 
[a] They use short-tag ? instead of ?php. Anyone have some good
search/replace style Regex (ideally for ZendStudio/Eclipse) that will run
through all the files in the project and fix those? There are lots of cases
to account for such as a space after the ? or nospace or a newline or even
other text (which are all valid cases).
 
[b] The other thing they do use use register_globals in the php.ini file. Is
there a good way to see all the variables that a page uses? Something I can
print at the bottom of the page on my dev box - ideally with enough
introspection to know where that variable originated from, and then I can
start converting things to $_GET, $_POST,  $_SESSION, $_COOKIE, etc.
 


Re: [PHP] regex or 'tidy' script to fix broken ? tags and introspection of variables

2011-08-09 Thread Camilo Sperberg
For the first one, it may be that zend studio does have an internal script to 
do the job. Check the general preferences tab, template stuff. Please note that 
?= is also valid and should be replaced to ?php echo instead. Also the 
short if version 1 == 1 ? True : false should be replaced if i'm correct.

Second question: zend studio displays all variables used by a script by 
clicking the arrow next to te file name. If you want to display it in runtime, 
you can:
print_r($GLOBALS);

Sent from my iPhone 5 Beta [Confidential use only]

On 09-08-2011, at 19:40, Daevid Vincent dae...@daevid.com wrote:

 I've inherited a bunch of code and the previous developers have done two
 things that are really bugging me and I want to clean up.
 
 [a] They use short-tag ? instead of ?php. Anyone have some good
 search/replace style Regex (ideally for ZendStudio/Eclipse) that will run
 through all the files in the project and fix those? There are lots of cases
 to account for such as a space after the ? or nospace or a newline or even
 other text (which are all valid cases).
 
 [b] The other thing they do use use register_globals in the php.ini file. Is
 there a good way to see all the variables that a page uses? Something I can
 print at the bottom of the page on my dev box - ideally with enough
 introspection to know where that variable originated from, and then I can
 start converting things to $_GET, $_POST,  $_SESSION, $_COOKIE, etc.
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php