Android Question View php in webwiew

Discussion in 'Android Questions' started by Khairy Abdelhamid, Sep 9, 2019.

  1. Khairy Abdelhamid

    Khairy Abdelhamid Member Licensed User

    Dear All,
    Greetings,

    I retrieve message from remote database, it seem like as following :

    <p><span style="font-size: 13px;">Product <b>information</b></span></p>

    it seem like part of php script.
    so, I add header and footer to make it as part of HTML like the following :

    <html>
    <body>
    <?php
    $string = "&lt;p&gt;&lt;span style=&quot;font-size: 13px;&quot;&gt;Product &lt;b&gt;information&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;";
    $string = html_entity_decode($string);
    echo $string;
    ?>
    </body>
    </html>


    but the webview didn't view it

    The code (of what mentioned above) as following:

    Dim str As String
    str = "<html><body><?php $string =" & Chr(34) & "&lt;p&gt;&lt;span style=&quot;font-size: 13px;&quot;&gt;Product &lt;b&gt;information&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;" & Chr(34) & ";$string = html_entity_decode($string); echo $string; ?></body></html>"
    Webview1.LoadHtml(ss)
    'ProdWeb.LoadUrl("www.vertex-technology.com")
    Webview1.Invalidate



    After many testing, I found that : Webview didn't view any php script inside,

    Any suggestion to view the above message.

    Thanks in advance.

    best regards
     
  2. yfleury

    yfleury Active Member Licensed User

    On web server running php, php return a html code.
    The webView do not handle php code because webview don't have a php engine
     
    Erel and KMatle like this.
  3. Brandsum

    Brandsum Active Member Licensed User

    Code:
    Dim str As String
    str = 
    "&lt;p&gt;&lt;span style=&quot;font-size: 13px;&quot;&gt;Product &lt;b&gt;information&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;"
    Webview1.LoadHtml(str)
     
  4. DonManfred

    DonManfred Expert Licensed User

    no, it is kind of encoded html code

    You should decode the html before sending the result (echo)
    PHP:
    $string "&lt;p&gt;Blah blah description is here blah blah&lt;p&gt;"# this is the code from the database.
    $string html_entity_decode($string);
    #$string = strip_tags($string); # Remove htmlcode (if you want)
    echo $string# This is what you should return to the calling B4A
     
    José J. Aguilar and Erel like this.
  5. MarkusR

    MarkusR Well-Known Member Licensed User

    because you will have html, the output of
    &lt; is the < char
    &gt; is the > char
    &quot; is "
     
  6. Khairy Abdelhamid

    Khairy Abdelhamid Member Licensed User

    First many thanks for all,

    Many thanks for Mr. Brandsum and Mr. DonManfred and Mr. MarkusR
    I test all solutions:
    for solution from Mr. Brandsum
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Dim str As String
    str = "&lt;p&gt;&lt;span style=&quot;font-size: 13px;&quot;&gt;Product &lt;b&gt;information&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;"
    Webview1.LoadHtml(str)
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    The output in webview seem like " <p> ... </p> " as shown in attached image


    for the solution from Mr. DonManfred
    I write it as following :
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Dim str As String
    str = "<html><body><?php $string = " & Chr(34) & "&lt;p&gt;&lt;span style=&quot;font-size: 13px;&quot;&gt;Product &lt;b&gt;information&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;" & Chr(34) & "; $string = html_entity_decode($string); $string = strip_tags($string); echo $string; ?></body></html>"
    Webview1.LoadHtml(str)
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    The webview didn't display any things,
    - If I write right code as you suggest ?
    - may be webview old version ??, and need to use other library ??

    Thanks in advance
    Best regards
     

    Attached Files:

  7. MarkusR

    MarkusR Well-Known Member Licensed User

    in the first the start and end is missing <html><body>
    and in the second php script is executed via a php.exe interpreter that outputs something.
    php is a installed part of a web server, i guess you saw a webside with .php ending,
    this file contains the php script inside this <?php a script is here ?>
    inside of php you can output text with echo into the http request result.
     
    Last edited: Sep 11, 2019
  8. Brandsum

    Brandsum Active Member Licensed User

    Code:
    Public Sub decode(Raw As StringAs String
        
    Return Raw.Replace("&quot;",QUOTE).Replace("&apos;","'").Replace("&lt;","<").Replace("&gt;",">").Replace("&amp;","&")
    End Sub

    Dim str As String
    str = decode(
    "&lt;p&gt;&lt;span style=&quot;font-size: 13px;&quot;&gt;Product &lt;b&gt;information&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;")
    Webview1.LoadHtml(str)
     
    Erel likes this.
  9. Khairy Abdelhamid

    Khairy Abdelhamid Member Licensed User

    Dear Mr. Brandsum
    your code run, really many thanks
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice