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
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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.