What’s the deal with short_open_tag?

A friend asked me today:

Why isn’t short_open_tag set to On in php.ini at [servers you set up] or in general?

Basically short_open_tag allows you to use <? and <?= in addition to <?php when formatting code. The latter can be very useful if you are using PHP as a templating language—like with Savant or no templating system at all.

Many people think that there is a security reason for this. For the life of me, I can’t really see the security problem with the setting though I can see the security problem with the coding. That is… if you code using short_open_tags, then you run the risk of running that code on a server where this variable it is off somewhere and suddenly you are dumping PHP code to people’s browsers. But that almost never happens and really if you have a configuration issue, you have bigger problems.

The real reason is simply that it violates valid XML markup to use short tags. Simply put, let’s say you have an example where your PHP page has to generate a valid XML file that needs a XML directive.

<?xml version="1.0" ?>

With short_open_tags, this will generate a fatal error in the PHP engine! The workaround is to do something nasty like

echo '<'.'?xml version="1.0" ?>';

(or some such). As more websites contained XHTML or some weird sort of sacrifice to the Gods of all things XML (SOAP, XMLRPC, REST-XML), it was sooner convenient to admit defeat and just start coding in valid XML markup.

It violates valid xml. It was not recommended for use because it isn’t guaranteed to be on everywhere. Ever since then people have been in the habit of not using short tags just in case they are off. Soon, it became part of the php.ini-recommended and short tags, like asp_tags and the alternative syntax for control structures got relegated to the dustbin of history.

What is the alternative syntax for control structures? Let’s not go there. 😉

Terry takes the Oklahoma High School Civics Test

1. What Is the Supreme Law of the Land?

The Ten Commandments.

2. What Do We Call the First Ten Amendments of the Constitution?

The New Deal.

3. What Are the Two Parts of the U.S. Congress?

Communists and Capitalists.

4. How Many Justices Are on the Supreme Court?

None. This is a trick question. Everyone knows the only people in court are the judge, jury and executioner.

5. Who Wrote the Declaration of Independence?

Jesus.

6. What Ocean Is on The East Coast of the United States?

The Mexican Ocean.

7. What Are the Two Major Political Parties in the United States?

Republican and Socialist.

8. We Elect a U.S. Senator for How Many Years?

Until they die or get caught in a wide stance.

9. Who Was the First President of the United States?

Ronnie Raygun.

10. Who Is in Charge of the Executive Branch?

Donald Trump.

Continue reading about about Oklahoma after the jump

Dock tweaks in Snow Leopard

Besides the obvious fact that contextual menus are now in inverted type and resemble overlays (making them easier to read), the Dock preferences has a hidden gem.

minimized windows can now disappear from the dock

Minimized windows can now disappear from the dock.

To find the minimized windows, click and hold to activate exposé (note the lightbox background)—the minimized windows now appear as a smaller preview in the lower part of the screen.

Nice. But the UI seems to resemble Ajax’d websites more and more.

Zynga hiring PHP developers

As someone who worked at Tagged, I can say that profit-sharing with game developers like Zynga have been instrumental to make our revenue numbers. If they make this much off us, I shudder to think how much they’re pulling in from open API networks like Facebook and MySpace.

(Not to mention way to many hours wasted on Mafia Wars and Poker. ;-))

In any case, another PHP job posting…

Continue reading about Zynga is hiring after the jump

Re-enabling Visor in Snow Leopard

Visor rocks.

What it does is add a system-wide hotkey to open Terminal as an overlay. The problem is it doesn’t work in Snow Leopard.

A little investigating implied that the problem was that SIMBL is not updated for 64-bit. So the trick is to simply “Get Info…” on Terminal and have it launch in 32-bit mode…

(Re-enabling Visor)

Now if only Logitech Control Center worked in Snow Leopard. I know the application is suck, but I’m getting tired of weird finger yoga to get at the control key on my Logitech DiNovo Mac Edition Keyboard. 🙁

Fail-safe never is

“He reassured me by telling me that when he looked back on his career, all the work he was most proud of was done under circumstances just like that, where it seemed impossible, where there wasn’t enough time, there wasn’t enough money, and everyone had set the bar really high for themselves.”

From a Variety article on Pixar (via Flackette).