Android Question View php in webwiew

Adamdam

Active Member
Licensed User
Longtime 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
 

yfleury

Active Member
Licensed User
Longtime 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
 
Upvote 0

Brandsum

Well-Known Member
Licensed User
B4X:
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)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
it seem like part of php script
no, it is kind of encoded html code

I retrieve message from remote database
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
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
because you will have html, the output of
&lt; is the < char
&gt; is the > char
&quot; is "
 
Upvote 0

Adamdam

Active Member
Licensed User
Longtime 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
 

Attachments

  • Screenshot_20190910-185301.jpg
    Screenshot_20190910-185301.jpg
    78.3 KB · Views: 845
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime 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:
Upvote 0

Brandsum

Well-Known Member
Licensed User
B4X:
Public Sub decode(Raw As String) As 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)
 
Upvote 0
Top