Php variable

General discussions related to php

Moderators: macek, egami, gesf

spherecraft
New php-forum User
New php-forum User
Posts: 3
Joined: Mon Jul 15, 2013 5:09 am

Php variable

Postby spherecraft » Sat Aug 03, 2013 8:52 pm

Hello i have a html. and i have a content like this

Code: Select all

<div class="sidebar-stats"><a href="{$url}/index.php?a=profile&u={$username}"><span style="font-size: 18px; font-family: 'wf_SegoeUILight', 'Segoe UI', 'Segoe UI Light', 'Segoe WP Light', 'Tahoma', Arial, Verdana, sans-serif; font-weight: bold; color: #000;">{$messages}</span> Bytes</div>
   <div class="sidebar-stats"><a href="{$url}/index.php?a=profile&u={$username}&f=followers"><span style="font-size: 18px; font-family: 'wf_SegoeUILight', 'Segoe UI', 'Segoe UI Light', 'Segoe WP Light', 'Tahoma', Arial, Verdana, sans-serif; font-weight: bold; color: #000;">{$followers}</span> Followers</a></div>
   <div class="sidebar-stats"><a href="{$url}/index.php?a=profile&u={$username}&f=following"><span style="font-size: 18px; font-family: 'wf_SegoeUILight', 'Segoe UI', 'Segoe UI Light', 'Segoe WP Light', 'Tahoma', Arial, Verdana, sans-serif; font-weight: bold; color: #000;">{$following}</span> Following</a></div>


i want to add a new variable which is the product of the 3 variablers the $follow,$followers,$bytes and i will divide it by three. how can i do it? cause i try

Code: Select all

{$follower} * {$bytes}
it just displaying as it is. thanks for thelp!

MarioParty
New php-forum User
New php-forum User
Posts: 42
Joined: Tue Aug 02, 2011 2:52 am

Re: Php variable

Postby MarioParty » Sun Aug 04, 2013 1:58 am

Code: Select all


<?php
$new_variable 
= ($follow*followers*bytes)/3;
echo 
$new_variable;
?>

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Php variable

Postby johnj » Tue Aug 06, 2013 10:52 pm

$temp1 = bcmul($follow,$followers, 2);
$temp2 = bcmul($temp1,$bytes,2);
$new_variable = bcdiv($temp2,3,0); // change 0 to some other number if you need more precision
echo ' New Variable is: '.$new_variable;


Return to “PHP General”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests