Help! Replacing parts of PHP files

My apologies if this is a dumb question.
I'm trying to copy a file and change a a small section of that file. How can I change that small section?
I tried doing so with by converting the byte array into a string, but how do you convert a string back into a byte array? Is there a better way of doing this?
Thanks for your help (I've been working on this problem all day :-( )
  public static void copyFile(File in, File out, int q) throws Exception {
    FileInputStream fis  = new FileInputStream(in);
    FileOutputStream fos = new FileOutputStream(out);
    byte[] buf = new byte[1024];
    int i = 0;
    String temp = "";
    while((i=fis.read(buf))!=-1) {
          temp = buf.toString();
          String explicitid = "explicitid=" + name[q];
          temp.replaceAll("explicitid=8", explicitid);
      fos.write(buf, 0, i);
    fis.close();
    fos.close();
  }

Let the I/O classes do the byte[]/String conversions for you; that's what they're there for. Another problem with your code is that you aren't doing anything with the result of the replaceAll() - it doesn't change the original string, it creates a new one. Try this (adapted from code on this page):
    public static void copyFile(File in, File out, int q) throws IOException {
        BufferedReader reader = new BufferedReader(new FileReader(in));
        BufferedWriter writer = new BufferedWriter(new FileWriter(out));
        //... Loop as long as there are input lines.
        String line = null;
        while ((line=reader.readLine()) != null) {
            writer.write(line.replaceAll("explicitid=8", "explicitid=" + name[q]));
            writer.newLine();   // Write system dependent end of line.
        //... Close reader and writer.
        reader.close();  // Close to unlock.
        writer.close();  // Close to unlock and flush to disk.
    }

Similar Messages

  • Help - Loading Remote XML/PHP File On AIR For Android

    Hi guys
    Just a quick question here. I'm developing an android app which requires a small amount of text data to be retrieved via a remotely hosted on a web server.
    It works fine on a desktop machine but when it comes to testing it on a cellphone it refuses to load the XML file.
    The data file I'm using is a simple XML file for now, but eventually it will be replaced with a PHP file which generates XML.
    I'm uisng Adobe Flash Pro CS6 and have set the target to AIR 3.4 for Android. The INTERNET setting on the android permissions has been checked.
    The code is a simple URLLoader as follows:
    ============================
    private var _appDataXML:XML;
    private var _xmlLoader = new URLLoader();
    _xmlLoader.addEventListener(Event.COMPLETE, _onXMLLoaded, false, 0, true);
    _xmlLoader.load(new URLRequest("http://www.example.com/data.xml"));
    private function _onXMLLoaded(e:Event):void
         _appDataXML = new XML(e.target.data);
         _xmlLoader.removeEventListener(Event.COMPLETE, _onXMLLoaded);
    ============================
    Is there any reason why this works on a desktop but fails to work when tested on a cellphone? Could I have missed something?
    Any help would be appreciated. Thanks!

    Thanks for the response. I did as you asked and looked at the internet permissions which by the
    way was already checked.
    I then managed to solve this issue in a very bizarre way. I originally wrote the app in Flash CS5.
    I recently purchased a subscription to Flash CS6 and after recompiling under CS6 it still exhibited
    the same behaviour. But when I unchecked and then rechecked the internet permissions the app
    somehow fixed itself and is now working.
    Not sure what's going on here but it all seems OK now. Thanks!

  • How do I find and replace text in PHP files?

    How can I in CS3 make sitewide changes to the text in PHP pages without changing variable names etc that have the same name?
    For example if I have an installation of a PHP forum and I want to change every instance of the word 'forum' to 'message board'...
    If I used the 'inside tag' search with " as the tag, then if "" contained a variable called 'forum' it would also be changed and therefore corrupt the code....
    Is there a simple way around this?
    Thanks!
    I'm using CS3 on Windows Vista.

    It looks like you're trying to find and replace source code, so you may be able to look at the various places that are looked at when finding and uncheck the ones that don't apply.
    But, if it's all source code then that won't help.  One thing that may work is to expand the search option - for example if the work "forum" that you're wanting to change it preceded by another word, or character or something that sets it apart, then do you find on that. You can expand that search phrase as far out in either direction that you need to to make it different, if of course that is practical in your situation.
    The only other way I can think of is to somehow create an exception rule, but I'm not sure if that's possible or how to do it.

  • Townsend php file not showing using mamp

    Hi
    I'm not sure exactly whether to publish this question in the general dw forum or php forum, so please bear with me.
    Thank you in advance for your help.
    I am using dw cs3 and am currently doing the David Powers tutorial on setting up a MAMP site for PHP using the Cafe Townsend detail and the comments.php file.
    My MAMP is set up with the Apache port on 8888, and the SQL port on 8889.
    (This has worked fine as a localhost for sites built with both xhtml and xsl so I think the problem may be the SQL)
    The fact that the timetest.php displays fine in both Safari and Firefox supports this view.
    In both Firefox and Safari, the following addess displays:
    http://localhost:8888/php_test/comments.php
    But the page remains blank.
    In Live Data I am told that the problem is:
    1 - the testing server is not executing php files, or
    2 - or the folder does not map to the testing server (the fact that the timetest works suggests it does)
    Dw tells me the connection has been made successfully on:
    localhost:8889
    The column fields from the sql database, appear in the databases window with (text required etc, as a parameter behind them).
    Am I doing something wrong, or could the comments.php file be corrupt?
    Please help.
    Tx.
    Regards,
    Gordon Eddey

    Murray, you superstar. Thanks.
    It's 17h37 here in Johannesburg,so I'll go on line later and mark the
    question answered, as the broadband becomes fat and sluggish at this hour.
    Using the suggested:
    <?php ini_set('display_errors',1); ?>
    Showed me that the file was still picking up an earlier
    ('Connections/connTest.php');
    in which I had taxed up the settings and had replaced with
    ('Connections/phptest.php').
    Simply changing to ('Connections/phptest.php'); and replacing the
    connTest.php file with phptest.php throughout the page resulted in the file
    working.
    I have to say that you have helped me most of my dw3 questions and I thank
    you for that.
    Regards,
    Gordon

  • When I tried to run php file I am getting the following error message, "/home/karthick/Desktop/PHP files/third.php could not be opened, because the associated helper application does not exist. Change the association in your preferences." How to fix this?

    When I tried to run php file I am getting the following error message, "/home/karthick/Desktop/PHP files/third.php could not be opened, because the associated helper application does not exist. Change the association in your preferences." How to fix this?

    first, you just asked me to use MS file Explorer to see what the properties were.,..and to ask what happened. Yes - that's on my hard drive. The problem I have is opening word files in a DB that is web enabled.....I've used Firefox browser for that, and everything else , for years...... When I look at the Tools, and options on FireFox., as your support page noted.....NOTHING is listed in the Applications tab....hence my note asking for help. The file I need to open is a Word file out on a web enabled DB. It's not on my hard drive - I have to problems opening docs there - but for that, I don't use Firefox

  • Need help replacing a file in AE

    Ok, here is my problem, I made a project on another computer and then I transfered to my computer. I dragged all of the images and sounds but ONE very important image. I downloaded that same image from online and I need help replacing the corrupted old image with the new one. Here is a picture with more detail.
    I tried copy & pasting the layer properties and effects, but that didn't work. Any ideas?
    Thanks,
    Emal

    For instructions on swapping out a footage item's source file, "Replace layer source with reference to another footage item".

  • Need help with simple php files

    I have simple php files that are setup with includes for a header, sidebar and footer... all other data is within the file. There is no dynamic info on the pages, yet I cannot get the files to load up in InContext. Is there a way to make this work?
    I can get an html file to work flawless, but something seems to stop the php file from working.
    Thanks,
    Ken Henderson

    What I mean is, whenever I try to edit any file with a php extension, I get a 404 error... even a simple file with no includes. I created a php file with one line of text within an editable region and I still could not edit it with InContext.
    The site I'm trying to work with is http://www.thunderbirdchemical.com
    The homepage is index.php
    The simple test file I made is test.php
    Thanks for your help.
    Ken

  • Replacement parts please help

    After spending $200 on the wrong display card replacement...
    Is there a place where a sole can go to find out what replacement parts are compatible with all the different versions of G5s?
    Thanks, Rick

    Hello people and Thank You, you are the best.
    I spent the weekend researching, based on your comments. And you are right, there are little choices. For me anyway. I have the first dual processor that came out (system profiler says "model: powermac7,2" - whatever that means).
    There are no PCI-X cards and 2 AGP cards that would be an upgrade from the fried ATI 9800 I had.
    Besides the ATI X800, I saw on Apple's site they still say the GeForce 6800 Ultra is needed for Dual link (will be needing) even tho it is discontinued and can't find anywhere. This card appealed to me because it does not have the ADC connector which I don't need.
    So I guess I will get the ATI X800 and a $100 ADC converter so I can run 2 DVI monitors. So much for the G5s being "built for expandability".
    Am I missing anything?
    Thanks again, Rick
    DPG5   Mac OS X (10.4.6)  

  • Spry Dynamic Tabs - reCAPTCHA is missing when loading external php file

    Hello,
    I have solved all my problems lately on this forum.
    But now im converting my site to use Dynamic tabs, and something goes wrong.
    The dynamic tabs load content from external files. It loads html but i think something goes wrong with php and my buttons.
    You need to know ALL is working perfect on the old site.
    2 problems;
    I dont know how to convert my buttons to this new style.
    I dont know why the reCAP suddently is missing.
    Why is reCAPTCHA missing?
    SOURCE HTML (index.html);
    <?php include("PHP/form.php"); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:spry="http://ns.adobe.com/spry">
    <head>
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
         <title>Wientjes Voegwerk &amp; Renovatie - Home</title>
        <meta http-equiv="Content-Language" content="NL" />
         <meta http-equiv="imagetoolbar" content="no" />
         <meta name="MSSmartTagsPreventParsing" content="true" />
        <meta name="description" content="Wientjes Voegwerk en Renovatie is een voeg- en renovatiebedrijf gespecialiseerd in gevelrenovatie. Dagelijkse werkzaamheden zijn het voegen van nieuwbouwwerk, en alle voorkomende vormen van gevelrenovatie. Ik geef uw woning, garage of schoorsteen de aandacht die het verdient en ben trots op het resultaat van mijn werk!"/>
        <meta name="keywords" content="Voegwerk, Renovatie, Reinigen, Impregneren, Muur, Voegen, Steen, Woning, Garage, Schoorsteen, Bedrijf, Gevel, Wientjes, Uitslijten, Kappen, Fundering, Vorstschade, Metselen, Metselwerk, Vocht" />
        <meta name="author" content="Rob Nijlaan" />
        <link href="CSS/Style2.css" rel="stylesheet" type="text/css" />
        <script src="JAVASCRIPT/SpryTabbedPanels.js" type="text/javascript"></script>
        <script src="JAVASCRIPT/SpryEffects.js" type="text/javascript"></script>
         <script src="JAVASCRIPT/SpryData.js" type="text/javascript"></script>
        <script src="JAVASCRIPT/xpath.js" type="text/javascript"></script>
         <script type="text/javascript">
         <!--
         function FadeAndUpdateContent(ele, url){
              try {
                   Spry.Effect.DoFade(ele,{
                        duration: 500, from: 100, to: 0, finish: function() {
                             Spry.Utils.updateContent(ele, url, function() {
                                  Spry.Effect.DoFade(ele,{ duration: 500, from: 0, to: 100 });
              catch(e){ alert(e); }
         -->
         </script>
    </head>
    <body>
    <div id="WContainer">
      <div id="WHeader" align="center"> <img src="Art/VoegenRenLos.png" width="540" height="58" alt="Voeg en Renovatiebedrijf" /><br />
        <img src="Art/WientLogo.png" width="600" height="136" alt="Wientjes Voegwerk &amp; Renovatie" /> </div>
      <script type="text/javascript">
         var dsTabs = new Spry.Data.XMLDataSet("data/data.xml", "tabs/tab");
         function loadContent(panel,url){
              Spry.Utils.updateContent(panel,url);
         Spry.Data.Region.addObserver("example1Region",dateLoadedCallback);
         function dateLoadedCallback(notificationType, notifier, data){
              if (notificationType =="onPostUpdate"){    
                   row= dsTabs.getRowByRowNumber(0)
                   if(row){
                        loadContent('0',row.url)
         </script>
      <div id="example1Region" spry:region="dsTabs">
        <div id="dynamicTabs" class="TabbedPanels">
          <ul class="TabbedPanelsTabGroup" >
            <li spry:repeat="dsTabs" class="TabbedPanelsTab" onclick="loadContent('{ds_RowID}','{url}');" tabindex="0">{title}</li>
          </ul>
          <div class="TabbedPanelsContentGroup">
            <div spry:repeat="dsTabs" id="{ds_RowID}" class="TabbedPanelsContent"></div>
          </div>
        </div>
        <script type="text/javascript">
                var t1 = new Spry.Widget.TabbedPanels("dynamicTabs");
                 </script>
      </div>
      <div id="WFooter" align="center">
        <p class="footer">Wientjes Voegwerk &amp; Renovatie     ,    03- '02       »      Site by ;    <b>Rob Nijlaan</b></p>
      </div>
    </div>
    </body>
    </html>
    Dont mind the extra javascripts they are not used for now (like SpryEffects.js) its for future use.
    SOURCE XML (data.xml);
    <?xml version="1.0" encoding="UTF-8"?>
    <tabs>
        <tab>
            <title>
              tab 1
              </title>
            <url>../data/HOME.html</url>
        </tab>
        <tab>
            <title>Tab2</title>
            <url>examples/tab2.html</url>
        </tab>
         <tab>
            <title>Tab3</title>
            <url>examples/tab2.html</url>
        </tab>
         <tab>
            <title>Tab4</title>
            <url>../PHP/form.php</url>
        </tab>
    </tabs>
    The html file loads like it should be, but the php form has problems.
    See it yourself: http://www.wientjesvoegwerk.nl/index2.html
    The tab 1 displays a html file like it should.
    The tab 4 displays the contact form but you will see the reCAPTHCA is missing.
    I have really no clue why it happens, exept maybe its a PHP issue.
    Maybe the script isnt compatible with non-html documents...
    Can someone please tell me whats the problem and if there is a solution????
    How do i change this button?
    I used this in my previous site:
    <table class="Button"  >
         <tr>
         <td style="padding-right:0px" title ="Home">
         <a href="#" title="Home" style="background-image:url(/Buttons/Home.png);width:172px;height:75px;display:block;"><br/>
         </a></td>
         </tr>
    </table>
    But the dynamic script uses {title} to get the <title> out of the xml.
    I tryd to put this straight into the title tags in the xml but obviously it wont work.
    And i really dont have a clue how to change this.
    My button has a mouseover img. Basicly its 2 buttons in 1 img stacked on top of each other.
    Like this: http://www.wientjesvoegwerk.nl/Buttons/contact.png
    Because of the CSS script it hovers to the right position.
    Part of SOURCE CSS (Style.css)
    .Button a{display:block;}
    .Button a:hover{background-position:left bottom;}
    a.Button {display:none}
    How can i change the xml and the script so "title" can be replaced with the button.
    Or how can i change the button so the mouseover works and the script still takes the button-img from the xml???
    Any help would be nice, because im finnaly in a postition to finish this site, and this is the only blockade left to conquer...

    Maybe it is not liking that the index page is an HTML page and not a PHP page. Try this way:
    In your form.php, remove the following code:
    <?php
    require_once('recaptchalib.php');
    $publickey = "6LfKNwwAAAAAAEdS6PjiDSHRQBDOYrGcM8R1eQQm"; // you got this from the signup page
    echo recaptcha_get_html($publickey);
    ?>
    Replace it with:
    <script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6LfKNwwAAAAAAEdS6PjiDSHRQBDOYrGcM8R1eQQm"></script>
        <noscript>
              <iframe src="http://api.recaptcha.net/noscript?k=6LfKNwwAAAAAAEdS6PjiDSHRQBDOYrGcM8R1eQQm" height="300" width="500" frameborder="0"></iframe><br/>
              <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
              <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
        </noscript>
    The replacement code is the same code that is outputted from the recaptchalib.php file.

  • Firefox keeps asking me to open/download PHP file when it used to be able to display properly.

    I use to be able to view local PHP files normally in Firefox with the PHP parts not rendered while the HTML parts are. Now all it does is ask whether I want to open or save it.
    I've tried editing FF options so that it previews in FF but it doesn't accept any changes. I've cleared my cache and all that. I've tried deleting the mimeTypes.rdf file thing but I can't even find the folder it's in. I've tried disabling/enabling "prompts.tab_modal.enabled" in about:config and restarting FF.
    All are no-go solutions.
    Web PHP pages are loading properly, this problem only comes when I'm trying to load local PHP files. I don't want to install XAMPP or PHP on my computer just to view local files as I never had this problem before.
    In the meantime, I've installed Chrome and it's loading a simple local PHP file just fine whereas FF is asking me to save/download when opening the SAME file. Thanks in advance for any help.

    Yup, deleting mimeTypes.rdf and re-starting did the trick this time. Thanks very much!
    Also, on a somewhat related note, I cannot view mozillazine.org and any sub-domains under it in any browsers. This may be happening to other users as well?
    It's always stuck at "Waiting for ..." or "Connecting to ..." and that's it. Then FF gives up with a "Server connection time-out" notice. Clearing cache and all that doesn't work because I was trying to view those pages before starting this topic.

  • How do I compensate for only one ADDT ' tNG_config.inc.php file with many Registration pages to build?

    My dynamic site has a lot of different languages funneled into one website, using various cookies, url params, php includes, etc. all to obtain similar info in different languages. Thank you David Powers.
    It is working really well and now I’ve come to the Registration section. Okay, so registration isn’t all that hard; I could do most of it with the standard Dreamweaver set of tools. Alas, I really like much of what ADDT has to offer with welcome email messages and activation and such.
    Here’s the setup: Obviously, with many different language people, I have many different databases for them. I did that becuase we’re expecting a big audience and I really don’t want to have all those different language names in the same table. Furthermore, these tables, whereby the students will login, will also contain a lot of information about their work so again, don’t want to have one massive table. I’ve divvied them up into tables by language and I’m using those tables to keep track of them and their work.
    I want to use ADDT’s User Registration Wizard and I have looked at all the neat stuff in the Control Panel/Login Settings.
    Here’s my situation: I notice that when I’m done with the configuring of one of the registration pages, I’m asked if I want to upload the tNG_config.inc.php page and that it has changed since the last upload. I saved a copy of the _config.inc.php and did a new registration form with the same info and when done, I compared the two _config.inc.php files. As one would guess, there is a small difference in the Connection string to the databases  $tNG_login_config["connexction"] = "connString_Ital_db".
    My problem is that I have 13 of these registration pages to do but ADDT only has the one tNG_config.inc.php. That’ll work great for the one with which it is associated, but the others will obviously break. I’ve looked through the code in the Registration pages, to find the ADDT link to the tNG_config.inc.php file hoping to rename it Italian, Spanish, etc, but the name of the file does not appear in the Registration page.  I realize that ADDT Control panel is designed for use on one site, and can then be used on others, with the changes etc. But my site seems a little unique since so many sites are actually in one.
    Has anyone whipped this problem before? I just don’t understand why there is no link in the head code of the Registration page to let me change it and to create more config files with different names. Thanks for you help!
    [Moved by moderator to appropriate forum]

    Hi Brian,
    I just tried to check all of ADDT´s "includes" files for any internal references (read: "require" or "require_once" statements) to the file "tNG_config.inc.php". So far I can only see this file referenced in the file "tNG.inc.php" (within the "$KT_tNG_uploadFileList1" array).
    So what could this mean ? Maybe you´ll have to make copies of the the original "tNG.inc.php" as well and save them as, say, "tNG.inc_ital.php" file plus make sure that these copies internally point to a different "tNG_config_ital.inc.php" file -- because it´s always the first mentioned file which gets referenced from e.g. an ADDT login page (see the "Load the tNG classes" - part)
    I want to use ADDT’s User Registration Wizard and I have looked at all the neat stuff in the Control Panel/Login Settings
    The Control Panel will always update the main "tNG_config.inc.php" file, so any further modifications will have to become manually applied to the custom files you´re creating.
    Cheers,
    Günter

  • Using Captcha within a .php file form

    Hello all - I need to add a captcha to an existing php form. The form is located in a .php file. I know this issue is not a Dreamweaver problem per se, but hoping someone here has had some experience with Captcha and .php files.
    when I add the following to the <form>
      require_once('recaptchalib.php');
      $publickey = "your_public_key"; // you got this from the signup page
      echo recaptcha_get_html($publickey);
    I end up with a blank white page. Note: the public key has been added in my file.
    There is a note in the tutorial that states:
      <html>
        <body> <!-- the body tag is required or the CAPTCHA may not show on some browsers -->
          <!-- your HTML content -->
    It is my understanding that <html> and <body> cannot/should not be added to .php pages. If this is true, can captcha work within a .php file?
    Thanks in advance for any and all help.
    Gene

    genoMU69 wrote:
    Nancy - thanks.
    What you're saying make sense.
    When I added the code below:
      require_once('recaptchalib.php');
      $publickey = "your_public_key"; // you got this from the signup page
      echo recaptcha_get_html($publickey);
    to the form with my actual public key included
    and:
    <?php
      require_once('recaptchalib.php');
      $privatekey = "your_private_key";
      $resp = recaptcha_check_answer ($privatekey,
                                    $_SERVER["REMOTE_ADDR"],
                                    $_POST["recaptcha_challenge_field"],
                                    $_POST["recaptcha_response_field"]);
      if (!$resp->is_valid) {
        // What happens when the CAPTCHA was entered incorrectly
        die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
             "(reCAPTCHA said: " . $resp->error . ")");
      } else {
        // Your code here to handle a successful verification
      ?>
    to the verify php, with the private key inserted,
    I end up with a blank white page, the form dissapears. I thought maybe it was because the html and body tags were not included with the parent page (of which the form is a part of)
    I will inbox you the parent form page so that you can see what I'm working with. Thanks again for you help.
    G
    At this stage I'd do a test.
    Just include the form and captcha stuff in a page on its own and see what the results are. (obviously include the <body><html> tags.
    If it works that means there is a problem with your real set up. If it doesnt it means there is certainly a problem with the way you have captcha set up.

  • Troubles using Javascript popoup  inside a PHP file

    I am trying something simple: to open a popup window trough a
    javascript code inside my PHP file and nothing happens: here is the
    code:
    $openwindow =
    "MM_openBrWindow('view.html','','width=300,height=300')";
    echo "<td><a href='#'><img
    src='images/button_blue.jpg' alt='Map' width='97' height='13'
    border='0' onclick=" . $openwindow . "/></a></td>";
    Also I am declaring such Javascript function at the beginning
    of the file... Please help me as soon as you can... it is driving
    me crazy... thanx in advance !

    .oO(David Powers)
    >Michael Fesser wrote:
    >> print "<a
    href='foo?id=$something'>bar</a>";
    >>
    >> Not a single escape character and very readable in
    an editor with proper
    >> syntax highlighting.
    >
    >I agree with Steve that this is a trivial example that
    doesn't really
    >prove anything.
    OK. At least it shows that escaping is not always necessary
    In a more complex example with more variables I would've used
    printf().
    >If $something is the only variable in a long section of
    >HTML, it's much more efficient to do this:
    >
    ><a href="foo?id=<?php echo $something;
    ?>">bar</a>
    I don't think efficieny is really an issue here.
    >Every time that the PHP engine encounters double quotes
    inside a PHP
    >block, the engine has to parse the content to find if any
    variables are
    >interpolated. In your example, there is a variable, so
    the effort isn't
    >wasted, but many developers use double quotes all the
    time, even if no
    >variable are included in strings. Although the difference
    in processing
    >time is only microseconds, it's an inefficient way of
    writing PHP.
    Did you ever encounter any performance issues just because of
    using
    "unneccesary" double quotes? Or by using string concatenation
    instead of
    the slightly faster
    echo $foo, $bar, $somethingElse ?
    I didn't, and I doubt I ever will. It may be not the best
    style and
    usually I use single quotes where possible, but I don't care
    too much,
    because other things are much more important.
    In fact I consider that all rather esoterical. If someone
    tries to
    "optimize" his code by avoiding double quoted strings where
    possible
    then IMHO he doesn't really have understood optimization at
    all. The
    real bottlenecks are not some syntactical sugar provided by
    PHP, but the
    algorithms and I/O operations. That's where optimization has
    to start.
    >However, I've seen a lot of inexperienced people post
    questions about
    >PHP problems, usually caused by the incorrect mixture of
    single and
    >double quotes.
    Agreed, me too. But often it's not just some lack of
    knowledge, but also
    the usage of the wrong tool. Many errors I've seen in
    beginner's code
    (especially the mentioned quoting problems) could've been
    easily spotted
    with proper syntax highlighting.
    >When you ask why they have coded it in such a convoluted
    >way, the answer is invariably "because it's a PHP page".
    Hmm, quite possible.
    >PHP is designed
    >to be embedded in HTML.
    True, but just because PHP is designed for this and that,
    doesn't mean
    that I always have to use it in that way. Remember
    register_globals and
    magic quotes - they were a fundamental part of PHP's design a
    while ago.
    >You can also include HTML in PHP functions.
    Now it gets really nasty. That's even more ugly than heredoc
    syntax. ;)
    With HTML embedded in PHP functions I always had the problem
    how to
    indent the code - either the source code looked bad or the
    final HTML.
    I never did it again.
    >If the HTML block contains a lot of variables or other
    dynamic code, I
    >agree that using print or echo is probably more efficient
    and easier to
    >read. However, when HTML is predominant, embed the
    dynamic stuff.
    As said - I consider it just personal preference. There are
    valid
    reasons for both ways.
    Micha

  • Find and Replace multiple line PHP comment

    Greeting everyone!
    Hopefully this question is asked in the right place.
    I have about 300 php files that have multiple line PHP
    comment that start with /* and end with this */. I want to remove
    all the comments since I am trying to reduce the file size as much
    as possible. The comments are no longer needed and I have tried
    many different configureation in the dreamweaver find and replace,
    but for the life of me I cannot seem to get it to work. I even
    tried useing regular expressions, but the astrick * is a wild card
    the the code tags contain an astrick.
    Is it possible to do this in dreamweaver, or will I need to
    hand edit every page?
    Thank for help
    example

    I am not sure of the exact syntax but open the find replace
    function on a page and play with find syntax search feature from
    the drop down menu . If I am not mistaken you should be able to to
    search from the beginning of a comment tag to the end of one and
    grab whats in between. From the help file
    Use the Find And Replace dialog box to search for text or
    tags in a document, and to replace the found material with other
    text or tags.
    Select Edit > Find And Replace.
    In the Search pop‑up menu, select Specific Tag.
    Select a specific tag or [any tag] from the pop‑up menu
    next to the Search pop‑up menu, or type a tag name in the
    text box.
    (Optional.) Limit the search with one of the following tag
    modifiers:
    With Attribute Specifies an attribute that must be in the tag
    for it to match. You can specify a particular value for the
    attribute or select [any value].
    Without Attribute Selects an attribute that must not be in
    the tag for it to match. For example, select this option to search
    for all img tags with no alt attribute.
    Containing Specifies text or a tag that must be contained
    within the original tag for it to match. For example, in the code
    <b><font size="4">heading 1</font></b>, the
    font tag is contained within the b tag.
    Not Containing Specifies text or a tag that must not be
    contained within the original tag for it to match.
    Inside Tag Specifies a tag that the target tag must be
    contained in for it to match.
    Not Inside Tag Specifies a tag that the target tag must not
    be contained in for it to match.
    (Optional.) To limit the search further, click the Plus (+)
    button and repeat step 3.
    If you didn’t apply any tag modifiers in steps 3 and 4,
    then click the Minus (-) button to remove the tag modifiers
    pop‑up menu.
    If you want to perform an action when the tag is found (such
    as removing or replacing the tag), select the action from the
    Action pop‑up menu and, if applicable, specify any additional
    information necessary to perform the action.

  • Unable to view php files in Design View?

    Need help! I cannot select design view when working with a PHP document, the DesignView option is disabled?
    My information.
    -          Dreamweaver CS5
    -          Mac OSX 10.6 snow Lepoard
    I have searched online and I also went through the FAQ but couldn’t find anything relating to this particular issue and my Professor at school said that I need to contact Adobe directly as design view should always be available but all that I would see in Design View are the HTML elements within the PHP file.
    The Design View button is disabled, I can not click on it all and so for my class assignments. I have to copy the PHP code into a new HTML document and only then am I able to view the html/php and edit the HTML elements, and then copy and paste it back into the PHP file once I have the html elements/design set up correctly.
    I did a similar “Set up PHP for Mac OS X – MAMP” to the version available here, could I have set this up incorrectly and that is why Design View is disabled?
    Thanks I appreciate your guys expertise and any help!

    Kanjan wrote:
    Need help! I cannot select design view when working with a PHP document, the DesignView option is disabled?
    Go to Dreamweaver > Preferences, and select File Types / Editors from the Category list on the left. Make sure that .php is NOT listed among the filename extensions in "Open in code view".
    Adding a filename extension to that list prevents files from being opened in Design view.

Maybe you are looking for