Using a PHP variable
I have :
<?php
//--------------TESTING VARIABLES------------
$test_String = $row_Latest['Map_String_Mob'];
print($test_String);
?>
I then try :
<a href=" <?php echo $test_String; ?>"
target="_blank">Link</a>
This causing an error when it opens the new page.
How do I use the PHP $test_String in the HTML section. ie
what is the
correct syntax.
Dim new_String
new_String = <?php echo $test_String; ?>"
<a href=" new_String" target="_blank">Link</a>
SteveW wrote:
> I have :
>
> <?php
> //--------------TESTING VARIABLES------------
>
> $test_String = $row_Latest['Map_String_Mob'];
>
> print($test_String);
>
> ?>
>
> I then try :
>
> <a href=" <?php echo $test_String; ?>"
target="_blank">Link</a>
>
> This causing an error when it opens the new page.
>
> How do I use the PHP $test_String in the HTML section.
ie what is the
> correct syntax.
>
>
> Dim new_String
>
> new_String = <?php echo $test_String; ?>"
>
> <a href=" new_String"
target="_blank">Link</a>
>
>
>
Hi Steve:
The syntax for the code in the body should be:
<?php echo($test_String); ?>
enthusiastically,
mark haynes
WebAssist.com
Similar Messages
-
Can you use a php variable to filter a recordset?
I've got a table of 'events', which have a description and
more importantly for this a month ID number. (1-12 for the months
of the year, when the event takes place) .
I've used php's date function on a page to fund out
numerically what month it is now $thismonth = date("n");
i want to filter my recordset by only bringing up events that
take place during the current month so where event_month =
$thismonth
IS this possible? It seems like it should be easy to do but I
can't get it to work.
Thanks in advance
Davejnkjnkjnkjnkjn wrote:
> i want to filter my recordset by only bringing up events
that take place
> during the current month so where event_month =
$thismonth
>
> IS this possible? It seems like it should be easy to do
but I can't get it to
> work.
Yes, it's very easy, but you need to do a little hand-coding.
In the
Advanced recordset dialog box set the end of the SQL query to
WHERE
event_month = 1. When you have saved the recordset, change
the SQL to
WHERE event_month = $thismonth.
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/ -
I am looking for a solution to a problem I am having with an
XSL stylesheet and trying to use a php variable. The page I am
working on is a page to display some information based on the
graduation year of a class (I work at a school). For example last
years graduating class of 2006.
I have a statement in the XSL sheet that limits the shown
data to only that class year
<xsl:for-each
select="school[class_of='2006']">
I would like to replace that 2006 above with a php statment
such as $classyear since on that page the data is to display the
variable is already present, but I cannot get it to work. I have
tried to place php in the XSL and also to change the extention etc
and they all produce errors. I am assuming that XSL just can't use
variables in it?
Any help would be greatly appreciated. I would hate to have
to duplicate that one XSL sheet for every class year.
thanks
chrisDavid,
thank you so much so far for you help, it does sounds like we
are talking about the same thing. I think I am getting close.
I do want to pass the value when the XSL sheet is embedded.
I tried that and it seemed to not work, says the variable is
not found (I am using the dreamweaver built in transform).
I am just getting into the more complex XML stuff so I
apologize for my lack of knowledege.
I have pasted some of the code below, any idea what I am
doing wrong?
the page where it is embedded is
http://www.nmhschool.org/news/test11.php
php doc with the embed and include
<?php
$mm_xsl = new MM_XSLTransform();
$mm_xsl->setXML("test11.xml");
$mm_xsl->setXSL("test11.xsl");
$mm_xsl->addParameter("yearXX", "2006");
echo $mm_xsl->Transform();
?>
http://www.nmhschool.org/news/test11.xsl
is the XSL
<xsl:for-each
select="Report/GroupHeader2/GroupHeader2_1[q1.CnPrAl_Class_of =
$yearXX]">
<table width="100%" border="1" cellspacing="1"
cellpadding="1">
<tr> blah blah blah........
http://www.nmhschool.org/news/test11.xml
is the XML data -
Unable to filter a recordset using a session variable
I have a volunteer application page and when the volunteer presses <Submit> their info is saved in a MySQl db table and a session variable is created containing the primary key of their record in the table, control is then passed to a "success page". The success page can access the session variable (I proved this by displaying the session variable on the success page) so my next step was to create a recordset in the success page with a filter using the session variable to select the appropriate row in the table, allowing me to display to the volunteer the info they submitted.
I set up a test success page which displays the session variable and one field of the volunteer info. When I test this I see the session variable displayed but the corresponding volunteer info field from the recordset is not displayed.
The volunteer application page is here www.hollisterairshow.com/volunteerapp.php and the successpage is here www.hollisterairshow.com/thanksvol.php
The code that creates the session variable in the volunteer application page is shown below
$_SESSION['volunteer_id'] = mysql_insert_id();
The code to display the session variable in the success page is shown below
<?php echo $_SESSION['volunteer_id']; ?>
The code to display the volunteer info is shown below
<h1> Thank You <?php echo $row_rsVolunteerApp['firstname']; ?>!! </h1>
The recordset definition is shown below
The success page test result is shown below, as you can see the volunteer's first name is not displayed immediately after the "Thank you" message but the session variable holding the correct primary key (41) is shown correctly.
Does anyone have an idea of what I'm doing wrong?
Thanks
TonyWhere did you put session_start()? It needs to be before the variable is accessed. It's obviously before the line that displays the value in your page, but is it before the SQL query is generated?
Also, have you checked in phpMyAdmin to see whether volunteernumber 41 has any values in the database? -
Selecting a MAX value from a table & displaying it on a form using OCI PHP
WinXP Pro SP3- 32bit
Apache/2.2.22 (Win32) mod_fcgid/2.3.6 PHP/5.4.0
PHP Version 5.4.0
Oracle epxress 11g
problem: output on form displaying Resource id #4 instead of the number from the table.
(maybe it's number to string conversion issue?)
$conn = oci_connect('system', 'mypassword', 'localhost/xe');
$query = "SELECT MAX(CustNo)+1 AS MAXNUM FROM customer";
$stmt = OCIParse($conn, $query);
OCIExecute($stmt);
OCIFetch($stmt);
echo OCIResult($stmt, "MAXNUM")." will be next number.";
//OCIFreeStatement($stmt); //frees the resources- use a the end!
$daNextNo = $stmt;
echo $daNextNo;
//$daNextNo = OCIBindByName($stmt, ":text", &$form_text, -1); //not sure how this works if it'll fix the issue
?>
<form name="Addcust" action="process_cust.php" method="post">
<input type="text" name="CustNo" value="<?php echo $daNextNo;?>" /></br>
output of complete code:
45 will be next number.Resource id #4
And inside the textbox it says: 45 will be next number.Resource id #4
how can I put the 45 into $php variable so i can use it in a textbox or on a label?
Thank you in advance .THanks. i couldn;t find the PHP section.
I figured it out
i used nextval() to convert the object to a string.
<?php
$conn = oci_connect('system', '1234', 'localhost/xe');
if (!$conn) {
$m = oci_error();
trigger_error('Could not connect to database: '. $m['message'], E_USER_ERROR);
$query = "SELECT MAX(CustNo)+1 AS MAXNUM FROM customer";
//$daNextNo = $query;
$stmt = OCIParse($conn, $query);
OCIExecute($stmt);
OCIFetch($stmt);
echo OCIResult($stmt, "MAXNUM")." will be next number.";
//OCIFreeStatement($stmt); //frees the resources- use a the end!
$daNextNo = strval(OCIResult($stmt, "MAXNUM")." .");
$daNextNo = strval(OCIResult($stmt, "MAXNUM"));
echo "danextNo: ";
echo $daNextNo;
?>
<form name="Addcust" action="process_cust.php" method="post">
<div>
<dl>
<dt>* <?php //echo $this->lang->line('cust_fn'); ?>: </dt>
<dd><input type="text" name="CustNo" value="<?php echo $daNextNo;?>" /></dd> -
Using a local variable in regex portion of replaceAll(regex, replacement)
While this works..
output = output.replaceAll("(HED>|AUT>)(.*)(</\\1)", "$1<![CDATA[$2]]>$3");
I'd like the list of alternation values to be contained in a variable, for example:
String nodeLIst = "HED>|AUT>";
output = output.replaceAll("(nodeList)(.*)(</\\1)", "$1<![CDATA[$2]]>$3");
The extension of this would be so I can store this stuff in a db as a list and avoid compilation on change, but please don't let this muddy the waters... :)
Any pointers are much appreciated. Links to specific reading material, etc. I've scoured Friedl's Mastering Regular Expressions to no avail. This approach is supported by some other regex engines I've used (perl, php, ORO?) but I'm new to Java.
TIA,
MarkI've scoured Friedl's Mastering Regular Expressions to no avail.Did you look on page 209? In the book, that code sample is labelled "Building Up a Regex Through Variables in Java". That should have been a clue. ^_^
But seriously, you're probably thinking of the interpolated strings you find in scripting languages like Perl, PHP, Ruby, etc.. But that's a feature of the language itself, not the regex engine, and Java doesn't work that way. (The $1, $2, etc., in the replacement string are processed by the Matcher class, in a very limited imitation of Perl's variable interpolation).
However, you can fake it pretty well with String's format() method: String regex = String.format("(%s)(.*)(</\\1)", theAlternation);
output = output.replaceAll(regex, "$1<![CDATA[$2]]>$3"); That way, you can easily escape the dynamic part, in case it might contain regex metacharacters: String regex = String.format("(%s)(.*)(</\\1)", Pattern.quote(theAlternation)); -
Im having trouble using $_GET[id]
my script opens an iframe at <iframe src=\"http://****.com.au/uploader/fileuploader/fileuploader_jnlp.php?id=".$_SESSION[user_id]."\" width=0 height=0 name=\"internal\"></iframe>";
my jnlp file looks like:
<?php header('Content-type: application/x-java-jnlp-file'); ?>
<jnlp spec="1.0+" codebase="http://www.****.com.au/uploader/fileuploader" href="fileuploader_jnlp.php">
<information>
<title>Uploader</title>
<vendor>Me</vendor>
<homepage href="index.html" />
<description></description>
</information>
<resources>
<j2se version="1.4"/>
<jar href="fileuploader.jar" main="true" />
<jar href="JimiProClasses.jar" />
</resources>
<application-desc main-class="fileuploader.FileUploader">
<argument>http://www.****.com.au/uploader/fileuploader/upload.php</argument>
<argument><?php echo $_GET[id]; ?>/</argument>
<!-- <argument>100000</argument> -->
<!-- <argument>thomas:test</argument> -->
</application>
<security>
<all-permissions/>
</security>
</jnlp>
but its not parsing the variable
I have tested for the variable using
<?php
echo $_GET[id];
?> on a standard php script and all works fine
I can even hard code the variable and it works
<?php header('Content-type: application/x-java-jnlp-file'); ?>
<?php $bob =367; ?>
<jnlp spec="1.0+" codebase="http://www.****.com.au/uploader/fileuploader" href="fileuploader_jnlp.php">
<information>
<title>Uploader</title>
<vendor>Me</vendor>
<homepage href="index.html" />
<description></description>
</information>
<resources>
<j2se version="1.4"/>
<jar href="fileuploader.jar" main="true" />
<jar href="JimiProClasses.jar" />
</resources>
<application-desc main-class="fileuploader.FileUploader">
<argument>http://www.****.com.au/uploader/fileuploader/upload.php</argument>
<argument><?php echo $bob; ?>/</argument>
<!-- <argument>100000</argument> -->
<!-- <argument>thomas:test</argument> -->
</application>
<security>
<all-permissions/>
</security>
</jnlp>
Can someone please tell me where I am going wronghi,
I'm gonna have to do exactly the same thing as you...
I haven't look at it yet, but I'd apreciate if you publish the working PHP script you fixed (if you managed that is ;-)).
thanx a lot.
Patrice. -
Php variable and xml processing
Hello there,
I have a problem that is driving me crazy! I have a php file
which creates an xml string from a sql query. The problem is that I
need to use a variable from an swf file to create the query. All
this should happen when i click a button on the swf page. The xml
file is created no problem but the variable is not used. i am well
able to use these POST variables in other php files. As you can see
the php file is called twice in the action script. Is this the
problem. The line: xmlData.load("get_max_sess.php"); is fine. I
stuck the other on one in - loadVariablesNum ("get_max_sess.php",
0, "POST"); after the fact and this doesn't work. is there a
confilct in calling the same file twice? Is the sendAndLoad
function an option? Also included below is my php file.
Thanks so much. I really hope you can help me!
****************************************************ACTION
SCRIPT**********************************
call_btn.onRelease=function(){
function processXMLData(success)
{loadVariablesNum ("get_max_sess.php", 0, "POST");
if (success)
var rootNode=this.firstChild;
var contentNode=findNode(rootNode, "guit_vol");
guitVol=getValue(contentNode);
var authorNode=findNode(rootNode, "guit_pan");
guitPan=getValue(authorNode);
var contentNode=findNode(rootNode, "guit_vis");
visGuit=getValue(contentNode);
_root.guitVis.gotoAndStop(visGuit);
//assign xml info to musician objects
_root.guitObj.drag._y=guitVol;
_root.guitObj.drag._x=guitPan*2;
else
content="Today's news is not found";
function getValue(node)
if (node && node.firstChild)
return node.firstChild.nodeValue;
return "";
function findNode(node, nodeName)
if (node.nodeName==nodeName)
return node;
for (var i=0; node.childNodes &&
i<node.childNodes.length; i++)
var foundNode=findNode(node.childNodes
, nodeName);
if (foundNode!=null)
return foundNode;
return null;
var xmlData=new XML();
xmlData.ignoreWhite=true;
xmlData.onLoad=processXMLData;//when xml data loads the
function at the top executes
xmlData.load("get_max_sess.php"); //loads the xml data from
this location
stop();
****************************************************PHP
FILE**********************************
<?php
$user_id=$_POST['user_id'];
// query database for records
$connection = mysql_connect('localhost', 'm27849_martin',
'Geraldine1') or die ("Unable
to connect!");
mysql_select_db('m27849_liveroom') or die ("Unable to select
database!");
$query = "
SELECT a.guit_sess_id, a.guit_vol, a.guit_pan, a.guit_vis,
b.bass_sess_id, b.bass_vol, b.bass_pan, b.bass_vis, c.drum_sess_id,
c.drum_vol, c.drum_pan, c.drum_vis
FROM guit_info a, bass_info b, drum_info c, users_sessions d
WHERE d.session_id =(SELECT max(a.session_id) FROM
users_sessions a WHERE a.user_id = '$user_id')
AND a.guit_sess_id = d.session_id
AND b.bass_sess_id =a.guit_sess_id
AND c.drum_sess_id = b.bass_sess_id
//(SELECT userid from auth WHERE username ='martin')
//here a variable could be inserted to call the relevant row
(session)
$result = mysql_query($query) or die ("Error in query:
$query. " .
mysql_error());
$doc = new DomDocument('1.0');
//The first element we create in the XML document is known as
the root element. Each XML document must have 1, and only 1, root
element. In this example I have called it 'root', but you can use
whatever name you like (such as the name of the PHP script which is
executing). Note that you have to create the element and insert it
into the document with two functions.
// create root node
while($row = mysql_fetch_assoc($result)) {
$user = $doc->createElement('session');
$user = $doc->appendChild($user);
foreach ($row as $fieldname => $fieldvalue) {
//Note that here I create a new element for the field and
then insert it as a child to the current database row, as
identified in $occ.
$child = $doc->createElement($fieldname);
$child = $user->appendChild($child);
//Now I must add the field value as a text node, then insert
it as a child element to the current field node, as identified in
$child.
$value = $doc->createTextNode($fieldvalue);
$value = $child->appendChild($value);
//These loops do not terminate until they have processed
every column of every row which has been retrieved from the
database.
} // foreach
} // while
echo $doc->saveXML();
//echo $doc->saveXML($child);
mysql_close($connection);
//from:
http://www.tonymarston.net/php-mysql/dom.html
?>Hi there,
I cracked it after a lot of to-ing and fro-ing! Apparently
you CAN send a variable and then load xml. Thanks so much for your
advice and interest. I am much obliged.
Marty Party
Check out my code below....
user_id=147;
submit_button.onRelease=function(){
function processXMLData(success)
if(success)
{_root.status_id="Success"
var rootNode=this.firstChild;
var contentNode=findNode(rootNode, "guit_vol");
guitVol=getValue(contentNode);
var authorNode=findNode(rootNode, "guit_pan");
guitPan=getValue(authorNode);
var contentNode=findNode(rootNode, "guit_vis");
visGuit=getValue(contentNode);
status_id=visGuit;
etc....
else
content="Today's news is not found";
function getValue(node)
if (node && node.firstChild)
return node.firstChild.nodeValue;
return "";
function findNode(node, nodeName)
if (node.nodeName==nodeName)
return node;
for (var i=0; node.childNodes &&
i<node.childNodes.length; i++)
var foundNode=findNode(node.childNodes
, nodeName);
if (foundNode!=null)
return foundNode;
return null;
var xmlData=new XML();
xmlData.ignoreWhite=true;
xmlData.onLoad=processXMLData;
//xmlData.load("get_max_sess.php");
var id:LoadVars = new LoadVars();
id.user_id = user_id;
//id.username = _root.username;
id.sendAndLoad("get_max_sess.php", xmlData, "POST");
Basic idea from
http://www.permadi.com/tutorial/flashXMLNewsExample/index.html
- Thank you!! -
Loading php variables into flash 8
i'm trying to load some vars into flash 8. i tried
loadvariables, loadvariablesnum, loadvars, google. can't figure it
out.
2 years ago when using flash mx trying the same thing, the
line:
loadVariablesNum("file",0);
was enough to do the trick.
but in flash 8 can't get it to work ;(
i have the simplest php file, something like this:
<?
$town = "where";
$person = "who";
$sex = "male";
print "town=$town&person=$person&sex=$sex";
?>
the use of variables is a must, so the solution
print "town=where&person=who&sex=male"
doesn't do me any good. actually this works.
so what's the correct way of loading this into flash 8?
thanks guyz.you can also use a FlashVars= parameter in your
<object><embed> code, IF you are using your PHP code to
also display your flash movie, and if you only need to pass these
variables once when the movie loads. If this is what you need to
do, use this....
<object ...>
....// other params .....
<param name="FlashVars" value="<?
echo var1name;
?>=<?
echo var1value;
?>&<?
echo var2name;
?>=<?
echo var2value;
?>" >
Though you will have to do that in two places, once in the
object code, and once in the embed code.
The embed code would look more like
<embed ...... FlashVars="<? //php similar to above
?>" ..... />
I have used this successfully to pass in variables when the
flash movie first loads, to pass in stuff like a URL for a link and
other info. There are a lot of different ways to pass values in to
flash. You can also use ExternalInterface.call and use Javascript
along with PHP to retrieve info at any time, but that is more
complex.
This may not be what you need - but you can still use
LoadVariables with Flash 8, as well. -
I have a page where I declare PHP variables which are then
used inside an include file.
When I try to edit the page in Contribute, I get a notice of
"Variable undefined" in the include.
This do work in Dreamweaver and it did work in Contribute in
other projetcs I have done.
Any suggestions?Hi Dont know if your still getting notifications on this but...
Did you ever find an answer as I am having the same issue.
I have tracked down why its not working but don't know how to stop it.
In Dreamweaver it keeps the php include reference as code when it saves the file, where as Contribute seems to process the include and dump the output back to the page.
This means that any common includes like headers and footers are no-longer included dynamically when the page loads as Contribute has embeded them when it created the page.
This alsos mean if you have included a php file with common functions that you may use on your site this will never appear and any variables you declare wont exist.
How rubbish is that!?
If anyone can help with this issue it will be greatly appreciated.
I'm hoping there is some simple Contribute comment I can put in to say "dont process this code - leave it alone!"
Thanks -
Accessing PHP variables (especially _SESSION)
Hi,
since CaioToOn! suggested here that I should use $_SESSION and I need to do this anyway, I spent the last 1+ hours trying to figure out how to do that. Sadly, I could not really figure it out except that there seems to be an issue with the session ID and that it has to be passed along to the swf file.
Can somebody please tell me how to read/write from/to PHP variables (not $_GET)?
P.S.: Here a simple example code (test.php and then the testintro.fla AS code):
<? session_start();
$_SESSION["intro"] = 0; // has the intro been played?
... // code for including the swf
?>
if(intro == 0)
myclip.gotoAndPlay(2); // play intro
intro = 1;
else
{ myclip.gotoAndPlay(24); } // skip the intro and go straight to the endnone of those reasons would require php to embed a swf.
normally, with flash, you could use a session variable to pass data from html to the swf. you set your session variable's data with a html form or something similar and then use flashvars to pass that info to your embedded swf(s).
you can also pass html data to an embedded swf using javascript and the externalinterface class. -
Is there a PHP variable that will fetch the TITLE of the file?
I learned (thanks to David Powers) that you can use $_SERVER['PHP_SELF'] to refer to your current URL, which is useful in situations like putting a "Share on Facebook" button on your page.
However, some of these social networking sites allow you to also put the Article Title in the same button, so I was wondering if there was a PHP variable I can use for *that*. This way, by specifying the title of the article in the aptly-named title tag of the page, I can put those "submit this page to" links as includes that don't need to be specifically-edited for each page.Create a variable for the title and use it in both places.
<?php
$title = 'Things you always wanted to know about...';
?>
<title><?php echo $title; ?></title>
// later on
<?php echo $title; ?>
Alternatively, if your page content is generated dynamically, you can store the title in the database.
Another technique would be to base the title on the page name.
$page = basename($_SERVER['SCRIPT_FILENAME'], '.php');
$title = ucwords(str_replace('_', ' ', $page));
That would store "About Us" in $title if the page is called about_us.php. -
Why we use customet exit variables?
hi friends,
why we use customer exit variables. can u give me some examples at what scenerio we use
default/user entry, formula, text, hierchies and hierchies. ( with processing type is customer exit)
can i get atleast 1 scenerio for 5 types variables?
Thanking u
suneel.Hi Suneel
Check info about Exits,
Replacement Path
You use the Replacement Path processing type to specify the value that automatically replaces the variable when you execute the query or Web application
check this link explains step by step
http://www.sd-solutions.com/documents/SDS_BW_Replacement%20Path%20Variables.html
Customer Exit:
If you need to use a processing type other than manual entry/default value, replacement path, SAP exit, or authorization, then a customer exit gives you the option of setting up a processing type for variables, tailor-made to your specific needs.
The customer exit is designed as an enhancement that you can configure with customer-specific logic
SAP Exit:
SAP exits are delivered content variables. Before creating any custom variable exit, its advisable to check if there are any SAP exits delivered to do the same functionality.
Check these links for SAP and Customer Exits,
To see SAP Exits -> Use Tcode SMOD
To See Customer Exits -> Use Tcode CMOD
There are projects to which Exits are assigned. Selects the relevant projects.
What is User Exit:
http://www.sap-img.com/abap/what-is-user-exits.htm
How to find then:
http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm
All Exits List:
http://www.easymarketplace.de/userexit.php
Thanks,
Sudhakar. -
Search/Replace for/with php variable name
Hi all.
I have just updated from Dreamweaver 5 to 5.5 and now I am missing a very handy functionality.
What I want to do is to replace all occurences of $a with $b.
In Dreamweaver 5 that was very easy by using "Find and replace":
Find in: All open documents
Search: Sourcecode
Find: $a
Replace: $b
Active options: Match case and Match whole word !!!!
Now in Dreamweaver 5.5 the option "Match whole word" is automatically disabled as soon as I enter a $ (dollar) in the search field.
I assume this has something to do with regular expressions but I do NOT check the option "Regular expression" in the search and replace dialog.
Is this a bug?
What are my options now.
If I don't have the possibility to to tick "Match whole word" my search does also replace all occurrences of $abc and $answer etc. with $b.
Thank you for your helpsamet2011 wrote:
I have Dreamweaver 5 and 5.5 running parallel on my computer.
I can confirm that the way I described and used to use is working on Dreamweaver 5.
I was the person who informed Murray that Dreamweaver CS5 and CS5.5 both behave the same way. I have just checked as far back as CS3, and it also disables "Match whole word" when you enter a dollar sign in the Find field of the Find and Replace dialog box. In fact, that option is disabled whenever you enter any nonalphanumeric character (except an underscore) in that field. It's not limited to dollar signs.
Why it's not disabled in your version of CS5 is a mystery.
However, to solve your problem, you don't need either a regex or "Match whole word". Simply type the name of your PHP variable followed by a space into the Find field. Also add a space after the name of the variable you're using as the replacement.
What "Match whole word" does under the hood is to use a regular expression to find a word break. As long as you leave a space between your variables and any following code, simply adding the space to your search will do the trick.
However, if you have cases where a variable is followed by a comma, closing parenthesis, or some other character, you will need to use the following regex:
Find: \$variable_name\b
Replace: $new_name
The \$ looks for a dollar sign. The variable_name matches the literal text of the variable name (replace it with the actual text you're looking for). The \b matches a word break in exactly the same way as "Match whole word".
In the Replace field, $new_name is the literal name of the new variable. -
I have a lot of included files in my site. At the end of each
included file,
I close the sql, but would also like to close the variables
used to produce
the HTML.
I'm having a hard time with my searching getting some
relevant results. Can
somebody help me here on what I"m looking for?
TIA,
Jon Parkhurst
PriivaWeb
http://priiva.net.On Thu 24 Aug 2006 04:36:46p, crash wrote in
macromedia.dreamweaver.appdev:
> I have a lot of included files in my site. At the end of
each included
> file, I close the sql, but would also like to close the
variables used
> to produce the HTML.
>
> I'm having a hard time with my searching getting some
relevant
> results. Can somebody help me here on what I"m looking
for?
I'm not sure I follow you here. Are you saying that you want
to limit
the scope of the PHP variables to the included file, so that
in something
like this:
<?php
include_once('fileA.inc');
include_once('fileB.inc');
include_once('fileC.inc');
?>
you can have a variable, say $crashsVariable, in fileA.inc,
fileB.inc and
fileC.inc, and have it take on a separate value in each of
them, but not
affect any of the others?
Without doing any experimentation... Using the
include_once()s makes the
include files, and thus all their code, part of the larger
code block.
AFAIK, the scope of a variable would be the calling file, so
the answer
would be no.
The PHP docs[1] have this to say:
The scope of a variable is the context within which it is
defined.
For the most part all PHP variables only have a single
scope. This
single scope spans included and required files as well.
but go on to add:
However, within user-defined functions a local function
scope is
introduced. Any variable used inside a function is by
default limited
to the local function scope.
So if you use $crashsVariable within a function within the
included file
(or, for that matter, the main file), it's local in scope.
Otherwise, a
variable exists for the entire page.
If you've spent the include file building a long string of
text, which is
eventually output as HTML:
<?php
$myvar = "<head>\n";
$myvar .= "<title>$myDynamicTitle</title>\n";
echo $myvar;
?>
the only way I know would be to do something like
$myvar = '';
Hopefully David Powers or somebody who actually knows might
check in.
[1]
http://www.php.net/variables.scope
Maybe you are looking for
-
How to create is Dialog or JDialog without close button
I want to add a dialog report the current step of work in the GUI and I don't want it to be closed manually. How can I get rid of the close button on the top right side of the dialog? Thanx for any help or clue given.
-
Won't start after trying tomactivate windows 7
Hi my friend just tried to set up my mac book to run windows as well os x. Well, when I tried to activate windows 7 it told me to restart but when I did it made the start up sound and showed a blank white pagebutwent to a black screen and repeated.h
-
Gnome-java Widget question (sorry if this is the wrong section)
I have created three files, yes i know naming conventions and spelling is an issue, but bare with me. I plan to clean all this up as soon as I get this issue figured out. right now I am flinging mud like a howler monkey. File One is a test file that
-
Sound Issues with K8N Neo4 Platinum
Over the last few days I've not been able to get any sound through the onboard line out socket in my pc. I only built it 2 weeks ago and havent noticed until the other day when I first used speakers. So for about 3 days now I've gone through ALL of t
-
How do I uninstall iWork?
How do I uninstall iWork?