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
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 _________
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 _________
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 ___________
b) forward slash
c) backward slash
d) either nothing or a forward slash
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
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.
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 __________
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 __________
Explanation: You need to add the following code –
function confirmDelete($db, $url)
$e = retrieveEntries($db, '', $url);
<form action="/simple_blog/admin.php" method="post">
<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" />
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
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 __________
Explanation: If the function is successful, you send the user to the main page. If it fails, you stop 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.