My Math Forum  

Go Back   My Math Forum > Science Forums > Computer Science

Computer Science Computer Science Forum


Reply
 
LinkBack Thread Tools Display Modes
June 20th, 2017, 01:14 AM   #1
Newbie
 
Joined: Jun 2017
From: Romania

Posts: 5
Thanks: 0

PHP Hexadecimal - pls help - stucked

Dear,

Can someone please help me to understand this code:

1
2
3
\$d = 'A8';
for (\$n=0; \$n<5; \$n++)
echo ++\$d /


How can you get A9 B0, B1?

Is there any good math book to explain me all of the math functions in PHP?

Last edited by skipjack; June 20th, 2017 at 11:19 AM.
pvesel is offline  
 
June 20th, 2017, 04:04 AM   #2
Global Moderator
 
Joined: Dec 2006

Posts: 17,908
Thanks: 1382

I haven't checked the syntax, but the idea is that the echo statement is executed 5 times. Each time, $d is incremented before being used by echo. Your question seems to assume something else occurs.

As far as I know, PHP documentation is available online. Why do you want it in the form of a math book (as distinct from a PHP manual), and why just for the math functions?
skipjack is offline  
June 20th, 2017, 04:13 AM   #3
Newbie
 
Joined: Jun 2017
From: Romania

Posts: 5
Thanks: 0

Thank you for your answer. However this is pure math:

https://en.wikipedia.org/wiki/Hexadecimal and it is connected to the code above. However:
How can you get: A9 B0, B1

Math functions are the core of the php.

If anyone has any idea how to go through this, with any good books, samples will be rewarded. I went through w3 school all the task, read some books, but it is not enough for understand loops.
pvesel is offline  
June 20th, 2017, 04:54 AM   #4
Senior Member
 
Joined: Apr 2014
From: UK

Posts: 775
Thanks: 291

Do you mean A9, AA, AB (and AC, AD to complete the loop)?
weirddave is offline  
June 20th, 2017, 06:13 AM   #5
Newbie
 
Joined: Jun 2017
From: Romania

Posts: 5
Thanks: 0

For my code:

<?php\$d = 'A8';
for (\$n=0; \$n<6; \$n++) {
echo ++\$d . PHP_EOL;
}

I get result
A9 B0 B1 B2 B3 B4

Why? And how?

Last edited by skipjack; June 20th, 2017 at 11:20 AM.
pvesel is offline  
June 20th, 2017, 06:18 AM   #6
Member
 
Joined: Nov 2012
From: The Netherlands

Posts: 30
Thanks: 1

Quote:
Originally Posted by pvesel View Post
Dear,


Is there any good math book to explain me all of the math functions in PHP?
will this be of any help to you:

PHP: Math Functions - Manual

http://php.net/manual/en/book.math.php
hello_math is offline  
June 20th, 2017, 07:03 AM   #7
Newbie
 
Joined: Jun 2017
From: Romania

Posts: 5
Thanks: 0

I found this example on the site you gave me:

PHP: Incrementing/Decrementing Operators - Manual

The function is incrementation/decrementation

The site is good, but I need more details explanation with examples.

Last edited by skipjack; June 20th, 2017 at 11:35 AM.
pvesel is offline  
June 20th, 2017, 09:37 AM   #8
Newbie
 
Joined: Jun 2017
From: Romania

Posts: 5
Thanks: 0

I found my example on the page suggested. I would like further explanation regarding incremenation\decremenation, books with exercises...

Thank you
pvesel is offline  
June 20th, 2017, 11:00 AM   #9
Member
 
awholenumber's Avatar
 
Joined: Jun 2017
From: India

Posts: 63
Thanks: 3

Code:
<?php
$d="A8";

for ($n=0; $n < 6; $n++) {
	echo ++$d . PHP_EOL;
}
?>
PHP: Incrementing/Decrementing Operators - Manual

It helps ?

Last edited by awholenumber; June 20th, 2017 at 11:22 AM.
awholenumber is offline  
June 20th, 2017, 11:12 PM   #10
Senior Member
 
Joined: Apr 2014
From: UK

Posts: 775
Thanks: 291

I'm rather glad I don't use PHP, that's horrible
weirddave is offline  
Reply

  My Math Forum > Science Forums > Computer Science

Tags
hexadecimal, php, pls, stucked



Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
hexadecimal algorithm Techmaster Computer Science 7 August 26th, 2014 01:29 PM
Signed hexadecimal computation! eChung00 Computer Science 3 March 4th, 2013 02:59 PM
Binary to hexadecimal Igo Computer Science 3 September 7th, 2012 03:58 AM
Hexadecimal Addition... Primalscientist Computer Science 13 April 20th, 2011 12:41 PM
Hexadecimal Notation Primalscientist Computer Science 3 April 17th, 2011 03:31 AM





Copyright © 2017 My Math Forum. All rights reserved.