answersLogoWhite

0


Best Answer

you can use:

include($filename); // will give a warning if the file is not found

include_once($filename); // same, but only includes if the file isn't already included

require($filename); // will stop the script if the file is not found

require_once($filename); // same, but only includes if the file isn't already included

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the PHP command used to take a file name and inserts the file's contents into the script?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Basic Math

How do you create a script to upload a file in PHP?

Hope your requirement is to upload a file to server . follow this code. $files=array(); $file=handleUpload($_FILES); function handleUpload($upload_file){ if(!$upload_file) return; $files=array(); $file->file_orig_name = $upload_file['name']; $file->file_size = $upload_file['size']; $path_parts = pathinfo($file->file_orig_name); $file->file_extension = strtolower($path_parts['extension']); $file->file_mime_type = $upload_file['type']; $file->file_tmp_name = $upload_file['tmp_name']; return $files; }


What does the function require-once do in php?

PHP maintains four direct functions for bringing in code from other files/sources. require() and require_once() bring code in from another source and PHP will refuse to run if it cannot load those files. include() and include_once() bring code in just the same, but your script will continue to run if those files could not be parsed. Thus you would use it if the code is optional and not necessary. The _once() functions tell PHP to keep a list of required/included files so far and ignore the request if it's already been done somewhere else. Otherwise, it'll parse the file twice and could cause your script to fail because the functions, classes, etc defined during the second load would conflict with those loaded the first time.


How do you retrieve and save PHP variables using text files?

Saving and retrieving PHP variables to and from a text file is bad programming practice in most cases, and can have repercussions (for example, the possibility of a variable changing between any two times running a script, and the script not being prepared for the new value).There are better alternatives available, such as using a database system like MySQL, or a more standardized "text file" system using INI files. See the related links for information on MySQL and INI files. With that in mind:There are many routes to making a script that retrieves and saves PHP variables in a text file, but a simple and common one may use the functions file_get_contents and file_put_contents, along with others like preg_match.file_get_contents($filename) can be used to get the variables (and any other content) in our text file.file_put_contents($filename) can be used to save variables to our text file.preg_match($pattern, $string) can be used to validate a string and see if it matches the specified pattern.See the related links for more information on these variables.Before actually writing the script, a format of writing our variables (and their values) should be planned out. Simply put, what should your text file look like? For this example, we'll assume a style like this:var1 = "something"var2 = TRUEvar3 = 59The style rule we're going to use here is the name of a variable, followed by a space, an equal sign, and another space, then the PHP syntax of a variable value (var1 will be a string, var2 will be a boolean, var3 will be an integer, and such). A new line specifies a new variable declaration.Now lets go ahead and write our script. The one in this example will be called "index.php", but any name will do.index.php


How do you copy php files to a CD?

Create Data CD with any available CD burning software and insert the files. Burn.


What is the meaning of an index in PHP?

are you asking what is the meaning of an index in php as in index.php? index.php is the default file the web server will load if you don't indicate a file and only a folder. if your web site was example.com, and you make a subdirectory called /test, then if you wanted a script to run when they type www.example.com/test, then you would make a file called index.php and put it in the subdirectory called test. same is true with .html files

Related questions

Is mdelet a valid script command?

mdelete is a command to delete files over FTP. Whether or not it's a valid script command would depend on the scripting language.


What is the difference between cut and a copy command?

a copy command would copy the contents of the selection and when you paste it somewhere else, the original contents would still be there. the contents would be available in both the original location and the new location a cut command would remove the contents of the selection and when you paste it somewhere else, the original contents would be lost. it would be available in the new location only.


What does the command ls-al?

This command lists the contents of the current working directory in a long listing format, including normally hidden files.


What is a command in Unix?

Essentially, a command in Unix is a program that you execute for a certain purpose. It could be anything, from a shell script, to copying or deleting files, etc.


What can run either VBscript or Jscript to apply script files at the command line?

Windows Scripting Host (WSH)


When a user gives a command to modify the contents of a file is it actually a command to access folders within the file?

There are no folders within a file. Files are within a folder.


At can be used to run script files using VBScript or JScript from the Windows desktop or from a command prompt?

windows scripting host


What does the Al?

This command lists the contents of the current working directory in a long listing format, including normally hidden files.


Write a shell script that copies multiple files to a directory?

why not use the cp command to copy multiple files, i.e. cp file1 file2 file3 dir Rick


What can be used to run script files using VBScript or Jscript from the windows desktop or from a command prompt?

Windows Scripting Host (WSH)


How do you paste in vi?

You use the 'yank' and 'put' commands. You 'yank' the lines into a buffer (named a - z) and then go to the place where you want to paste or duplicate them, and use the 'put' command to insert them. You can also read entire files or portions of files with the 'r' command to paste contents into other files.


Write a shell script to sort all the files in the current directory in an alphabetical order and direct the sorted list to a new file?

The following simple shell command lists the contents of a directory (verbose), and redirects the output to 'newfile.txt': ls -l > newfile.txt See related links.