2014-06-20, 09:02
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
The problem is when i then do:
The output will look something like this:
So the output is 7 alpha numeric characters long
however when i run:
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:
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:
Can anyone advise what the heck is going on ? why is the count incorrect ?
I've also tried doing the following:
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:
The output is 7 characters long but the "value" of the variable is lost.
What is going on here ?
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
header("Content-type: text/plain");
echo "#!ipxe\n\n";
$serversn = "\${serial}";
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);
echo $serversn;
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);
echo $serversn;
OUTPUT is: ABCDEFGX
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 ?