Web host - 81Chapter 5Syntax and VariablesBoth of these statements will
81Chapter 5Syntax and VariablesBoth of these statements will cause the given sentence to be displayed, without displayingthe quote signs. (Note for C programmers:Think of the HTTP connection to the user as thestandard output stream for these functions.) You can also give multiple arguments to the unparenthesized version of echo, separated bycommas, as in: echo This will print in the , user s browser window. ; The parenthesized version, however, will not accept multiple arguments: echo ( This will produce a , PARSE ERROR! ); PrintThe command printis very similar to echo, with two important differences: .Unlike echo, printcan accept only one argument. .Unlike echo, printreturns a value, which represents whether the printstatementsucceeded. The value returned by printwill be 1if the printing was successful and 0if unsuccessful. (It is rare that a syntactically correct printstatement will fail, but in theory this return valueprovides a means to test, for example, if the user s browser has closed the connection.) Both echoand printare usually used with string arguments, but PHP s type flexibility meansthat you can throw pretty much any type of argument at them without causing an error. Forexample, the following two lines will print exactly the same thing: print( 3.14159 ); // print a stringprint(3.14159); // print a numberTechnically, what is happening in the second line is that, because printexpects a stringargument, the floating-point version of the number is converted to a string value beforeprintgets hold of it. However, the effect is that both printand echowill reliably print outnumbers as well as string arguments. For the sake of simplicity and uniformity, we will typically use the parenthesized version ofprintin our examples, rather than using echo. In addition to the printing functions discussed here, there are two printing functions usedmostly for debugging: print_r()and var_dump(). The point of these functions is to helpyou visualize what s going on with compound data structures like arrays, so we cover themalong with the details of arrays in Chapter 9. Variables and stringsC programmers are accustomed to using a function called printf, which allows you to splicevalues and expressions into a specially formatted printing string. PHP has analogous func- tions (which we will cover in Chapter 7), but as it turns out we can get much of the samefunctionality just by using print(or echo) with quoted strings. For example, the fragment: $animal = antelope ; $animal_heads = 1; $animal_legs = 4; print( The $animal has $animal_heads head(s).
); print( The $animal has $animal_legs leg(s).
); Cross- Reference07
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.