PHP logic not working
|
2014-06-20, 09:02
(This post was last modified: 2014-06-20 09:08 by jhonny.)
Post: #1
|
|||
|
|||
PHP logic not working
Hi Guys,
I'm trying to get iPXE working with PHP and MYQSL. For some reason the PHP logic does not seem to be working. I've got the following code in a php file that ipxe chain boots: What its supposed to do is grab the serial number of the server and assign it to the variable: serversn Code: <?php The problem is when i then do: Code: echo $serversn; The output will look something like this: Code: ABCDEFG So the output is 7 alpha numeric characters long however when i run: Code: echo strlen($serversn); The output is equal to 9 !!!! instead of 7 !!!! No idea why that is, so i tried to add some padding on either side of the $serversn variable by doing the following: Code: echo str_pad($serversn, 9, "X", STR_PAD_RIGHT); The output should be: ABCDEFGXX The output is still the original 7 alphanumeric characters: ABCDEF Its only until that i change the str_pad parameter to 10 that one X will show up: Code: echo str_pad($serversn, 10, "X", STR_PAD_RIGHT); Can anyone advise what the heck is going on ? why is the count incorrect ? I've also tried doing the following: Code: $serversn = substr($serversn,0,7); That should cut the string contents of the $serversn variable to the first 7 characters. Instead what happens is when i echo out $serversn, it returns the following: Code: ${seria The output is 7 characters long but the "value" of the variable is lost. What is going on here ? |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
PHP logic not working - jhonny - 2014-06-20 09:02
RE: PHP logic not working - mastacontrola - 2014-06-20, 11:25
RE: PHP logic not working - jhonny - 2014-06-20, 12:01
RE: PHP logic not working - mastacontrola - 2014-06-20, 12:45
|
User(s) browsing this thread: 2 Guest(s)