This set of PHP Multiple Choice Questions & Answers (MCQs) focuses on “Updating and Deleting Entries”.
1. When you are building administrative links you’ll need to accept two arguments, which of the following are they?
a) URL of previous entry and URL of the entry you are working with
b) The current page and previous page
c) URL of previous entry and previous page
d) The current page and URL of the entry you are working with
View Answer
Explanation: Your function should look like this:
function adminLinks($page, $url)
{
//Build admin links here
}
2. Once your application can generate administrative links, you need to load those links into _________
a) php.ini
b) index.ini
c) index.php
d) start.php
View Ansewr
Explanation: You place your administrative links only on the full display of an entry, so you must place the call to load information from adminLinks() within a conditional statement
3. The URLs in the administrative links won’t mean anything to admin.php unless you modify _________
a) .htaccess
b) .adminaccess
c) .htmlaccess
d) .urlaccess
View answer
Explanation: You need to modify .htaccess with an additional rule that handles URLs passed in a link to admin.php.
4. The (|/) tells the server to match ___________
a) nothing
b) forward slash
c) backward slash
d) either nothing or a forward slash
View Answer
Explanation: The vertical pipe character (|) is the regular expression equivalent of “or”.
5. ([\w-]+) will match ___________
a) one word characters
b) one or more word characters
c) one or more word characters and/or hyphens
d) one or more word characters and hyphens
View Answer
Explanation: ([\w-]+), will match one or more word characters and/or hyphens—which is what your custom entry URLs consist.
6. You need to check whether ______ is set, to determine whether you’re editing an entry or creating a new one.
a) $_GET[‘url’]
b) $_SET[‘url’]
c) $_GET[‘admin’]
d) $_SET[‘admin’]
View Answer
Explanation: If an entry is being edited, you need to load the existing entry data and save each piece in a variable.
7. To identify entries marked for deletion, you check whether $_GET[‘page’] == ‘delete’ inside __________
a) index.php
b) index.ini
c) admin.php
d) .htaccess
View Answer
Explanation: In admin.php, you check whether $_GET[‘page’] == ‘delete’, then pass the entry URL to be deleted to a function.
8. To declare the function to confirm the deletion you need to add the code to __________
a) inc.php
b) functions.inc.php
c) include.php
d) functions.include.php
View Answer
Explanation: You need to add the following code –
function confirmDelete($db, $url)
{
$e = retrieveEntries($db, '', $url);
return <<<FORM
<form action="/simple_blog/admin.php" method="post">
<fieldset>
<legend>Are You Sure?</legend>
<p>Are you sure you want to delete the entry "$e[title]"?</p>
<input type="submit" name="submit" value="Yes" />
<input type="submit" name="submit" value="No" />
<input type="hidden" name="action" value="delete" />
<input type="hidden" name="url" value="$url" />
</fieldset>
</form>
FORM;
}
9. Your confirmation form submits your choice, via the _______ method, to ________
a) GET index.php
b) GET admin.php
c) POST index.php
d) POST admin.php
View Answer
Explanation: To process this, you need to add an additional block of code to the top of admin.php that determines what choices you’ve made and act accordingly.
10. When a user confirms that he wishes to delete an entry, that entry’s URL is passed to a function which removes the entry from the __________
a) index.php
b) function.inc.php
c) database
d) admin.php
View Answer
Explanation: If the function is successful, you send the user to the main page. If it fails, you stop the execution of the script and display an error, letting the user know that something went wrong.
Sanfoundry Global Education & Learning Series – PHP Programming.
To practice all questions on PHP Programming, here is complete set of 1000+ Multiple Choice Questions and Answers on PHP.
- Apply for Programming Internship
- Practice Programming MCQs
- Check MCA Books
- Practice MCA MCQs
- Check Information Technology Books