Jump to content

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

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.