在PHP中读取.grd文件

Found out GRD is a "gridded dataset file", but cannot see its contents using cat. I think it's in binary format, so it must be read in a different way. The problem is: only found examples in Fortran, R, MATLAB... I must convert the shell script below to PHP (that's only a partial code):

if test -s /path/${datemax}00tx.grd
then

# creating ctl file

echo DSET  /path/${datamax}00tx.grd >> $DIR/new-$customer.ctl
echo UNDEF  777.7   >> $DIR/new-$customer.ctl
echo TITLE CTL to view interpolated files >> $DIR/new-$customer.ctl
echo XDEF 176 LINEAR  -76 .25 >> $DIR/new-$customer.ctl
echo YDEF 160 LINEAR  -34 .25 >> $DIR/new-$customer.ctl
echo ZDEF 1  LINEAR  1 1  >> $DIR/new-$customer.ctl
echo TDEF 1  LINEAR 00Z01apr$yearmax 24HR >> $DIR/new-$customer.ctl
echo VARS 1 >> $DIR/new-$customer.ctl
echo maxval 0   99   Maximum Value>> $DIR/new-$customer.ctl
echo ENDVARS >> $DIR/new-$customer.ctl

echo MAXVAL

cat << eof | grads -bpc "$DIR/getvalues.gs" 
maxval
$customer
eof

fi

rm -f $DIR/new-$customer.ctl

Is it even possible to do this using another language like PHP, Java (my preferred one) or Python? This ugly script reminds me of Assembly.