How to declare a string variable?
P粉392861047
P粉392861047 2024-04-01 22:30:49
0
1
435

The first time this variable $totpro appears in my code is like this

$totpro = $totpro + $row['profitloss'];

I want to use it to aggregate all profits, however, I get this warning message when running

Warning: Undefined variable $totpro

But if I put this code before the previous code, it works fine

$totpro = "0";

I don't like using that code to declare a function, it tried

String $totpro

But I didn’t expect it to be successful. Now tell me how to define $totpro without having to use $totpro = "0";

P粉392861047
P粉392861047

reply all(1)
P粉937769356

If you want to sum numbers, the initial declaration should set the value to 0 (i.e. a number):

$totpro = 0;

You tried "0", which is a string. Technically, this works, but it's not the best approach.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!