Do you mean inside dot PHP file, Start with script tag; Write your code; End the script tag; And whatever your php code; 5. 1k Views Answer requested by. Amit Saini. How can the answer be improved? PHP 5 File CreateWrite PHP Write to File fwrite() The fwrite() function is used to write to a file. The first parameter of fwrite() contains the name of the file to write to and the second parameter is the string to be written.
The example below writes a couple of names into a new file called" newfile. txt" : Writing Your First Script And Getting It To Work. To successfully write a shell script, you have to do three things: Write a script; Give the shell permission to execute it Notice the semicolon (; ) after the PHP code you need to put a semicolon after each line of code in your PHP scripts. The semicolon is optional if you're only writing one line of code, as in this example.