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

  • SEARCH
  • Home
  • 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 8934671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:50:33+00:00 2026-06-15T09:50:33+00:00

I have a condition stored in a variable $condition = 1==1 and I want

  • 0

I have a condition stored in a variable $condition = "1==1" and I want to use the value of the variable in a conditional statement.

if($condition) { //$condition should be parsed as 1==1
    return true;
}

Is this possible? I’ve tried using var_export but apparently that doesn’t work.

if(var_export($condition)) {
    return true;
}

Any help will be greatly appreciated!

  • 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-15T09:50:34+00:00Added an answer on June 15, 2026 at 9:50 am

    After some discussion in the comments above we found out, that the condition itself is not the problem, but how it is passed to the function

    conditional_func($var . " == 'test'", $result);
    

    We realized, that it is not required to pass the first parameter as a string, but can use a boolean directly, thus we don’t need to evaluate the string at all.

    conditional_func($var == 'test', $result);
    

    As a sidenote: @BryanMoyles answer is right regarding the question, but remember, that eval() is evil (you can’t think of any pitfall, that may occur) and on the other hand there are only some very less quite esoteric usecases, where you can’t use another approach.

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

Sidebar

Related Questions

JS/JQuery Newb here! I have a value stored in variable, and I need to
I have a condition such as 'a==1' stored in property $(c) and I wanna
I have if condition and I want to disable or enable my actionLink button.
Say, you have a condition like this; if ($condition_1 && $condition_2) and you have
Possible Duplicate: php false place in condition I have noticed that a lot of
I have the following if condition statement if ( (strlen($data[70])>0) || ( (remove19((trim($data[29])) ==
I have managed to put this condition and rule below together to redirect a
Environment: SQL Server 2005 I have a stored proc which receives comma separated value
I am relatively very new to SQL queries but I have this stored procedure
I have this stored procedure, I was wondering if if exists will actually compare

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.