RE: [PHP] regex or 'tidy' script to fix broken <? tags and introspection of variables
| From: | Daevid Vincent | Date: | Wed, 10 Aug 2011 20:54:31 +0000 |
| Subject: | RE: [PHP] regex or 'tidy' script to fix broken <? tags and introspection of variables | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-314468@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Camilo Sperberg [mailto:unreal4u@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=59&t=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 WAAAAAAY 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" <daevid@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.
> >