mica123 Posted April 18, 2017 Share Posted April 18, 2017 I have finished the book which is very informative and I have the following questions:1) You say in Chapter 10 that user-defined functions add extramemory requirements to the PHP code and that they should not be usedif they call another PHP function or if they have just one line of code.Even so, I am not sure how one should go about it.It is difficult to see when they can be used or not.2) In the last Chapter 13, you have code that refers to running a query. For example: // Define the query: $query = "DELETE FROM quotes WHERE quote_id={$_POST['id']} LIMIT 1"; $retrieve = mysql_query($query, $dbc); // Execute the query. This code executes the query but I am confused. It seems to methat the code sets the variables - on the face of it is not actuallyrunning anything, yet it does. That's what I don't understand.Many thanks. Link to comment Share on other sites More sharing options...
Larry Posted April 19, 2017 Share Posted April 19, 2017 The answer to your first question is really: you'll learn in time. You'll find that when you do the same process multiple times in an application, it's probably a good candidate for a function. Just avoid creating them when the user-defined function just has a line of code (generally speaking). The example chapter at the end of the has an example of a user-defined function, too. As for the second question, I'm a bit confused by what you're asking. The first line defines the query and inserts a variable. The second line executes the query (i.e., the second line does the "running"). Link to comment Share on other sites More sharing options...
mica123 Posted April 20, 2017 Author Share Posted April 20, 2017 Thanks, Larry. Well, I got a little confused here because I was under the impression that if variables are defined, they don't actually run. However, I can see now that the second variable is a function which is supposed to be executed once the script is put to work. Thanks for your patience. Link to comment Share on other sites More sharing options...
Larry Posted April 24, 2017 Share Posted April 24, 2017 No problem at all! Let me know if you have any other questions! Link to comment Share on other sites More sharing options...
Recommended Posts