Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8079573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:08:56+00:00 2026-06-05T16:08:56+00:00

$op=$_POST[‘param’]; $statement=eval(return ($op);); in ‘param’, if there is a strange character such letter ‘jfsdf’

  • 0
$op=$_POST['param'];
$statement=eval("return ($op);");

in ‘param’, if there is a strange character such letter ‘jfsdf’ or something else the eval function does not work. How can I solve this problem?

eval function works only well defined entries such as ’54+4*3′ on the other hand if it is used entries such ‘6p+87+4’ it gives an parse error. Is there any way to warn user in order to enter a well defined statement

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:08:58+00:00Added an answer on June 5, 2026 at 4:08 pm

    First of all, depending on what you mean by “strange” character, you should implement function that verifies the string coming from outside.

    $allowed_chars = array('function', 'this' ); //..add desirable ones
    
    function is_alloved_char($char){
     return in_array($char, $allowed_chars);
    }
    

    RegEx is great for this when You Do except some performance down.

    In your situation str_pos() is great enough to match undesirable chars.

    so, your another function should be similar to:

    /**
     * 
     * @param string
     * @return TRUE on success, FALSE otherwise
     */
    function is_really_safe($char){
      global $allowed_chars; //just make this array visible here
     foreach ($allowed_chars as $allowed_char){
       if ( str_pos($allowed_char, $char) ){
         return false;
       }
     }
     return true;
    }
    

    Also, be VERY VERY careful with eval()
    If you use this function in product, then you are doing something wrong.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$_POST['asdf'] = 'something'; function test() { // NULL -- not what initially expected $string
post '/upload' do unless params[:file] && (tmpfile = params[:file][:tempfile]) && (name = params[:file][:filename]) return
$arrayOfEmails=$_POST[arrayOfEmails]; 1st question: $arrayOfEmails is now just an array in JSON notation. How would
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
// Post model return array( 'categories' => array(self::MANY_MANY, 'Category', 'categories_posts(post_id, category_id)') ); I already
Post methods handled by SuperController class due to code-sharing. I guess such as @Controller
Post your shortest code, by character count, to check if a player has won,
I'm trying to create an if statement in PHP that prevents a single post
.post is the class of elements which also have an unique id such as
Post-release, I have made one small change to one form in our development site

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.