Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 

 

Oracle Database Tips by Donald Burleson


 

Strings

Strings are the most frequently used type to describe free flowing text. The most basic notation is to place the desired string between double quotes, shown like this: $a="Using PHP with Oracle";. The variable $a is set to the same value as if an expression is written like this: $a='Using PHP with Oracle';. PHP recognizes both single and double quotes, but there is a significant difference. Text within the single quotes is not interpreted any further, while text within the double quotes is interpreted. In particular, special characters and variables are interpreted. The following script brings to light this meaning:

Example 2:

    <?php
    $a="Oracle";
    $b="Using PHP with $a";
    $c='Using PHP with $a';
    print "$b<BR>$c";
    ?>

The result from the script above looks like the following:

    Using PHP with Oracle
Using PHP with $a

The result would look like this because variable $bis assigned its value using the double quotes, while the variable $c is defined by using the single quotes. Because of the double quotes in variable $b, the value of variable $a is interpolated in value $b.  Single quotes disable such behavior. Interpolationcan be selectively inhibited even within the double quotes by using the backslash character (\).

If the assignment is written to variable $b as in the example below, the values of $b are the same as the variable of $c because the interpolation of the value of $a are inhibited by the backslash character.

    $b="Using PHP with \$a";

From the script above, <BR> is used within the print command to separate the values of the variables $b and $c. Why should one do this?  The results of the PHP scripts are displayed within the browser, which speaks HTML and in principle ignores new lines except within the preformatted strings.

So, in order to display the two values on two different lines, HTML should be used, not the old ASCII terminal logic. The example illustrates a bad programming practice. If it can be avoided, HTML tags should not be placed in the print command. The proper way of performing these responsibilities is illustrated in the next example.

There is another way of describing strings, called "in string". Before explaining what this means, view the much anticipated example:

    <html>
    <pre>
    <?php
    $a="Oracle";
    $b= <<< EOF
    This is a book about using the PHP
    programming language with databases,
    in particular with the $a database
    EOF;
    print $b;
    ?>
    </pre>
    </html> 

The script is embedded in an HTML file. Instead of placing a <BR> tag at the end of the each line, the script itself is placed between <pre> and </pre> tags, which mean that the text between is an externally formatted file and the new lines are displayed as such. This is the correct programming practice and should be followed whenever possible. In addition, look to the assignment of the variable $b.  Variable $b contains everything within the <<<  EOF and EOF; markers. The blank between the  <<< and EOF is required by the syntax. Variable $a is interpreted.  The result as expected is the following:

    This is a book about using the PHP
    programming language with databases,
    in particular with the Oracle database

This is so called in-string. Such notation is used when multi-line string is needed within the script. Using double quotes for multi-line string also works, but is deprecated.

See code depot for complete scripts

This is an excerpt from the book Easy Oracle PHP.  You can get it for more than 30% by buying it directly from the publisher and get instant HTML-DB scripts from the code depot:

Easy Oracle PHP
Create Dynamic Web Pages with Oracle Data

Includes online HTML-DB code depot

Buy it now for 30% off - Only $19.95
 

HTML-DB support:

For HTML-DB development support just call to gat an Oracle Certified professional for all HTML-DB development projects.

 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.