473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how can i add new string at the beginning of an existing file

1
how i can add or write new line or string at the beginning of an existing file
Apr 24 '13 #1
1 1204
omerbutt
638 512MB
Hi Aria ,

Expand|Select|Wrap|Line Numbers
  1. $File = "my-files/example.php";
  2. $Handle = fopen($File, 'w');
  3. $Data='<?php echo "hi"?>';
  4. fwrite($Handle, $Data);
  5. fclose($Handle); 
  6.  
hope it helps
regards,
Omer Aslam
Apr 24 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Rich | last post by:
I am trying to replace the word "test" in a file with the word "Change" without creating a new file using the following code: #! /usr/bin/perl -w open (IN, "+</path/to/file/test.html"); ...
2
by: Nico Grubert | last post by:
Hi there, I would like to open an existing file that contains some lines of text in order to append a new line at the end of the content. My first try was: >>> f = open('/tmp/myfile', 'w')...
1
by: wayne | last post by:
Dear all, may i know how can i delete the contents of an existing file using vc++?? also, i would like to know how can i delete the whole file? thanks alot wayne
4
by: SteveW | last post by:
Thanks to some good help from a previous post, I have been able to create well formed xml as part of a report logger app. However, I still have a small problem. When I add new xml to the log file,...
1
by: nasirmajor | last post by:
Dear all i have the following code for writing to the existing file. =========================== void AppendToFileEng() { SqlDataReader gr = null; string engpath2=""; gr =...
6
by: shalakasan | last post by:
Hi, I want to open a binary file and write to a specific location in File. Here is how my code looks like: int main() { long lbuf = 0; int lreadBytes = 0;
16
by: btopenworld | last post by:
Hi - question from a relative asp novice I have written to text files in the past, but always appending new data to the end of the text file. I now want to add the new data to the beginning of...
1
by: mamin | last post by:
Hi, I need to output result of my query to txt file. So I'm using -o parameter, for example: osql.exe -s (local) -d database1 -U sa -P sa -i 'c:\\queryFile.sql' -o 'c:\\output.txt' But it...
1
by: harishmitty | last post by:
Lemme explain exactly what am doing. Its pretty simple. String^ file_name = "c:\\test.txt"; StreamWriter^ sw = gcnew StreamWriter(file_name); sw->WriteLine("Hello"); When I do this, everytime...
5
sueb
by: sueb | last post by:
In my Access database, I have a button on a form that copies a set of existing Word documents to a location (associated with the record on that form). However, I don't want an existing file to be...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.