Jump to content

Math operation syntax help


kuyarey

Recommended Posts

My Mathematical operation is not working. Need help. Thank you in advance!
P.S.
Go easy on me I'm a noob in both the PHP language and these forums
 
<?php
//First ever serious php program starting from the basics
 
echo "Hello World</br>";
 
print "<br>(278909887*4)</br>";
 
print "This should come out in another line";
 
?> 
 
Output:
 
Hello World
 
(278909887*4)  ====> This is what I'm talking about
This should come out in another line

 

Link to comment
https://forums.phpfreaks.com/topic/296921-math-operation-syntax-help/
Share on other sites

The math operation needs to be done outside the string 

print "<br>" . (278909887*4) . "</br>";

Anything within a quotes is treated as-is. Only variables are expanded within double quoted strings. If you need to calculate/perform a function and use the result in a string you need to concatenate. Explained here http://php.net/manual/en/language.operators.string.php

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.