Jump to content

[SOLVED] php.ini What needs to be changed?


Boo-urns

Recommended Posts

I just moved my form to a new server when i was working locally with MAMP. Now the form fields are displaying the php code that I am outputting in the field.

 

For example:

<input type="text" name="email" id="email" value="<?= displayFormVal($email); ?>" />

 

In the form it's displaying: <? echo displayFormVal($email); ?> in the input.

 

What needs to be changed in the configuration?

 

Thanks!

-Corey

Link to comment
https://forums.phpfreaks.com/topic/140940-solved-phpini-what-needs-to-be-changed/
Share on other sites

I would change:

<input type="text" name="email" id="email" value="<?= displayFormVal($email); ?>" />

 

to:

<input type="text" name="email" id="email" value="<?php echo displayFormVal($email); ?>" />

 

<?= is PHP Shorthand and not all servers are set up for this. I am not sure how to set up your configuration to accept this but the above should work

To use short tags you must set short_open_tag to On. It's better to fix the code in the way dennismonsewicz said though.

 

Edit: On Linux you can write a small shell script like this to do it quickly:

#!/bin/sh
grep -rl <\?= /path/to/script/root | while read filename do {
sed "s/<\?=/<?php echo/g;" $filename > $filename.new
mv -f $filename.new $filename
rm -f $filename.new
}
done

 

I didn't test it and you might want to backup your files first. Don't mind that the syntax highlighting is messed up though.

To use short tags you must set short_open_tag to On. It's better to fix the code in the way dennismonsewicz said though.

 

Thanks! I was wondering how one goes about setting that up. I have used either way and as a good practice, imo, I got out of doing it cause I quickly found out that not all servers are setup for this config.

Yea i agree it is a better bet to just echo it out instead of the short tag.

 

I do have access to the php.ini file so i changed the short_open_tag to on.

 

However, before that I did try just to do the echo which was my first guess as well as many here but, it still outputted it in the field. When i changed the .ini file short_open_tag line it worked just fine.

 

So even if I used just regular echo output, why would it show up in the field? i.e.<?php echo $someVar; ?>

 

Thanks for the quick responses everyone!

-Corey

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.