Jump to content

is this possible?


mga_ka_php

Recommended Posts

how do you compute an equation inside a variable?

 

$row['equation'] - from database. example content: ORIGINAL_PRICE - (ORIGINAL_PRICE * 0.50)

 

example

define('ORIGINAL_PRICE', 49.97);
$value = $row['equation'];

 

is it possible?

This is what you need:

http://php.net/manual/en/function.eval.php

 

Store the equation in database as: $ORIGINAL_PRICE - ($ORIGINAL_PRICE * 0.50)

After that, you can do:

$value = eval($row['equation']);

Link to comment
https://forums.phpfreaks.com/topic/202339-is-this-possible/#findComment-1060967
Share on other sites

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.