Single-quoted strings
print 'I have gone to the store.';
print 'I\'ve gone to the store.';
print 'Would you pay \$1.75 for 8 ounces of tap water?';
print 'In double-quoted strings, newline is represented by \n';
Output
I have gone to the store.
I've gone to the store.
Would you pay $1.75 for 8 ounces of tap water?
In double-quoted strings, newline is represented by \n
Because PHP doesn’t check for variable interpolation or almost any escape sequences in single-quoted strings, defining strings this way is straightforward and fast.
VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Posted by admin | Posted in PHP, Theory Subjects | Posted on 18-11-2009
0
1: <!DOCTYPE html PUBLIC
2: “-//W3C//DTD XHTML 1.0 Strict//EN”
3: “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
4: <html>
5: <head>
6: <title>Calling a Function Dynamically</title>
7: </head>
8: <body>
9: <div>
10: <?php
11: function sayHello() {
12: print “hello<br />”;
13: }
14: $function_holder = “sayHello”;
15: $function_holder();
16: ?>
17: </div>
18: </body>
19: </html>
A string identical to the name of the sayHello() function is assigned to the $function_holder variable on line 14. After this is done, we can use this variable in conjunction with parentheses to call the sayHello() function. We do this on line 15.
Why would we want to do this? In the example, we simply made more work for ourselves by assigning the string "sayHello" to $function_holder. Dynamic function calls are useful when you want to alter program flow according to changing circumstances. We might want our script to behave differently according to a parameter set in a URL’s query string, for example. We could extract the value of this parameter and use it to call one of a number of functions.
VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Posted by albert | Posted in PHP, Theory Subjects | Posted on 16-11-2009
0
Multitasking is the ability of an operating system to run multiple programs concurrently. Basically, the operating system uses a hardware clock to allocate “time slices” for each currently running process. If the time slices are small enough—and the machine is not overloaded with too many programs trying to do something—it appears to a user as if all the programs are running simultaneously.
Multitasking is nothing new. On large mainframe computers, multitasking is a given. These mainframes often have hundreds of terminals attached to them, and each terminal user should get the impression that he or she has exclusive access to the whole machine. In addition, mainframe operating systems often allow users to “submit jobs to the background,” where they are then carried out by the machine while the user can work on something else.
Multitasking on personal computers has taken much longer to become a reality. But we now often seem to take PC multitasking for granted. As I’ll discuss shortly, to some extent the earlier 16-bit versions of Microsoft Windows supported multitasking but in a somewhat limited capability. The 32-bit versions of Windows all support both true multitasking and—as an extra bonus—multithreading.
Multithreading is the ability for a program to multitask within itself. The program can split itself into separate “threads” of execution that also seem to run concurrently. This concept might at first seem barely useful, but it turns out that programs can use multithreading to perform lengthy jobs in the background without requiring the user to take an extended break away from their machines. Of course, sometimes this may not be desired: an excuse to take a journey to the watercooler or refrigerator is often welcome! But the user should always be able to do something on the machine, even when it’s busy doing something else.
VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Posted by albert | Posted in PHP, Request | Posted on 16-11-2009
0
The fact that null pointers are represented both in source code, and internally to most machines, as zero invites unwarranted assumptions. The use of a preprocessor macro (NULL) suggests that the value might change later, or on some weird machine.
VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]