Register for your free account! | Forgot your password?

You last visited: Today at 09:52

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



php binary?

Discussion on php binary? within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
Wolfy.'s Avatar
 
elite*gold: 0
Join Date: Mar 2014
Posts: 219
Received Thanks: 27
php binary?

Can you write to a binary file with php, i don't understand too much php but in c# lets say it goes BinaryWriter BW = new etc... And then you write to a file lets say BW.This write etc... Can you do that with php?
Wolfy. is offline  
Old 05/05/2014, 21:42   #2
 
Mikesch01's Avatar
 
elite*gold: 203
Join Date: Sep 2007
Posts: 732
Received Thanks: 190
Hi,

I don't think you can do that because PHP is an interpreter language and C# is a compiler language. These are 2 different things.

There are very less operation which work in PHP for binary changes, like bitwise-OR or bitwise-AND.

What do you want to do exactly?
Mikesch01 is offline  
Old 05/05/2014, 22:35   #3
 
dryPants's Avatar
 
elite*gold: 0
Join Date: Mar 2014
Posts: 46
Received Thanks: 11
Quote:
Originally Posted by Mikesch01 View Post
Hi,

I don't think you can do that because PHP is an interpreter language and C# is a compiler language. These are 2 different things.

There are very less operation which work in PHP for binary changes, like bitwise-OR or bitwise-AND.

What do you want to do exactly?
With Ruby i can also write to binary files even it's a interpreted language
But I also think PHP can't do this but well, I'm far away from being an PHP expert.
dryPants is offline  
Old 05/05/2014, 23:38   #4
 
Luôô's Avatar
 
elite*gold: 5
Join Date: Dec 2009
Posts: 1,090
Received Thanks: 434
Maybe this ?
Luôô is offline  
Old 05/06/2014, 00:48   #5
 
Wolfy.'s Avatar
 
elite*gold: 0
Join Date: Mar 2014
Posts: 219
Received Thanks: 27
Let me tell you what i want: in c# we have this:

Code:
            FileStream FS = new FileStream(@"path" + Name + ".usr", FileMode.CreateNew);
                BinaryWriter BW = new BinaryWriter(FS);
                BW.Write(Password);
                BW.Write(Status);
So, it writes to a file like this, this is what i get on notepad:


No idea how you will see it...
Well is there a function in php that can make files same like this?
Wolfy. is offline  
Old 05/06/2014, 01:27   #6
 
Mikesch01's Avatar
 
elite*gold: 203
Join Date: Sep 2007
Posts: 732
Received Thanks: 190
Now it's more clearly.

Yes there are some file-handling functions in PHP.

These are the main file functions:
fopen
fwrite
fread
fclose

Tutorial:

You can also check out the file_put_contents function which Luôô already have written.

Mikesch01 is offline  
Old 05/06/2014, 09:46   #7
 
Wolfy.'s Avatar
 
elite*gold: 0
Join Date: Mar 2014
Posts: 219
Received Thanks: 27
After searching a bit i found out that the file is normal and there are only this:



That tntntn is the password, someone knows how to add those control characters or how they are named with php?

Edit: I made it with this works now thank you all for your help.

Code:
<?php
$file = 'people.usr';

$current = chr(3);
$current .= "ebago";
$current .= chr(0);
file_put_contents($file, $current);
?>
Wolfy. is offline  
Reply

Tags
php binary files


Similar Threads Similar Threads
Binary 38801, Latest binary.
03/24/2014 - Metin2 PServer Guides & Strategies - 75 Replies
This is latest binary unpacked. Has R6002 error. Hasn't any modification. https://mega.co.nz/#!BEV0jb6J!MPcP3xCGenYIGQXAzsV PeHiEx4wSCVHYDf9vBKpCPTs
[Relese]Tq Binary translation 98% + all Binary Files
07/07/2009 - CO2 Private Server - 20 Replies
#Removed
[HELP] CO binary
04/20/2009 - CO2 Private Server - 7 Replies
when i try to open the banary(5065) the msg server keep saying connecting but never connects i started at the morning and still didn't connect in the afternoon. help me plz thx



All times are GMT +1. The time now is 09:52.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.