Jump to content

PHP Binary Converter Help


jjacquay712

Recommended Posts

I wrote a script to convert an ip address to binary, but it isnt working, im new to php, so my syntax might be funny. can anyone tell me what might be going wrong?

 

                                              Thanks, John

 

The Error: Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in C:\wamp\www\bianary\script1.php on line 11

 

The Code:

 

<?php

if ( $_POST['1'] <= 128 ) {

$64 = $_POST['1'] - 128;    This line is line 11 on my php document

echo "1";

}else {

echo "0";

$_POST['1'] = $64;

}

 

if ( $64 >= 64 ) {

$32 = $64 - 64;

echo "1";

} else {

echo "0";

$32 = $64;

}

 

if ( $32 >= 32 ) {

$16 = $32 - 32;

echo "1";

} else {

echo "0";

$16 = $32;

}

 

if ( $16 >= 16 ) {

$8 = $16 - 16;

echo "1";

} else {

echo "0";

$8 = $16;

}

 

if ( $8 >= 8 ) {

$4$ = 8 - 8;

echo "1";

} else {

echo "0";

$4 = $8;

}

 

if ( $4 >= 4 ) {

$2 = $4 - 4;

echo "1";

} else {

echo "0";

$2 = $4;

}

 

if ( $2 >= 2 ) {

$1 = $2 - 2;

echo "1";

} else {

echo "0";

$1 = $2;

}

 

if ( $1 >= 1 ) {

echo "1";

} else {

echo "0";

}

?>

 

Link to comment
https://forums.phpfreaks.com/topic/100725-php-binary-converter-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.