How to convert to a link using Rrawurldecode()? [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a host of files that generate link like this for hosted files:
http://endertec.com.br/hf/see-img.php?img=http://www.endertec.com.br/hf/do.php?imgf=Fav2.png
But when I see link like this on Facebook, it looks like this:
http://endertec.com.br/hf/see-img.php?img=http%3A%2F%2Fwww.endertec.com.br%2Fhf%2Fdo.php%3Fimgf%3Fav2.png
So I researched ways to convert it, and got the following code:
<?php
$str = 'http://www.endertec.com.br'.$_SERVER['REQUEST_URI'];
$src = str_replace('see-img.php?img=' , '' ,stristr($str , 'see-img.php?img='));
string rawurldecode ( string $src )
echo '<img src="'.$src.'"/>';
?>
But for some reason it does not work, does anyone know how it might work?

You need to store your rawurldecode in something.. try something like this:
$decoded_src = rawurldecode($src);
echo '<img src="'.$decoded_src.'" />';

Related

HTML code gets displayed when it should not [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have the following PHP code:
<?php
$obrazek = the_post_thumbnail( 'product_page_image' );
list($nic,$nic,$nic,$nic,$nic,$obrazeklink,$nic,$nic,$nic,$nic,$nic) = explode('"', $obrazek);
?>
and $obrazek variable contains
<img width="1560" height="1170" src="http://takopix.com/wp-content/uploads/edd/2015/06/Melbourne-storm-1560x1170.jpg" class="attachment-product_page_image wp-post-image" alt="Melbourne storm">
but the HTML gets recognized even without echo... and explode doesn't work!
The function the_post_thumbnail is used to print the thumbnail markup. It returns nothing. You want get_the_post_thumbnail

Checking validity url in php [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Нi guуs. I russian php noob.
I have the following code:
if($rr['site']) echo '<a target="_blank" href="http://'.$rr['site'].'" class="">'.$rr['site'].'</a>';
Need to make a valid of the user a url HTTP there or not. Otherwise it outputs - http://http://siteurl
Prompt me how to do it? pliz
Maybe, there is a solution - How do I remove http, https and slash from user input in php
but i need an example with my code.
I would be grateful for any help.
I would do the opposite. Instead of removing http:// or https:// and then adding it again, I would just check if the string starts with http:// or https://, and add http:// only if it doesn't.
Something like:
if($rr['site']) {
$url = preg_match('/^https?:\/\//', $rr['site']) ? $rr['site'] : 'http://'.$rr['site'];
echo '<a target="_blank" href="http://'.$url.'" class="">'.$url.'</a>';
}

Apple JSON API not decoding properly in PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I find out about Apple lookup API and wanted to try something.
JSON: http://itunes.apple.com/lookup?id=443904275
It's only read resultCount, I can't read other data for example app name:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$json = file_get_contents('http://itunes.apple.com/lookup?id=443904275');
$data = json_decode($json,true);
$appname = $data['artistName'];
echo "<pre>";
echo ($appname);
exit;
?>
You need to understand the structure of the object. What you need is:
$appname = $data['results'][0]['artistName'];
Looks like you need to use $data['results'][0]['artistName']
...assuming $data['resultCount'] == 1.
You can always put http://itunes.apple.com/lookup?id=443904275 in your browser to see exactly what you're PHP is working with.
(Edit: what Jonathan said...)

Super easy php link construct [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
$out_terms[$term->name] = '' . $text . '';
Please help me check where the code gone wrong,any missing notes etc,as I am really 0 into php
$out_terms[$term->name] = sprintf('%s', $term_link, $text);
Try this (best construct) :
$out_terms[$term->name] = "$text";
or :
$out_terms[$term->name] = ''.$text.'';

How to get Dailymotion title [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Hi i am trying to get video title from dailymotion videos.
$imgid = $video_cek["embed"]; //this is dailymotion id (ex. xint71)
$hash = unserialize(file_get_contents("http://www.dailymotion.com/services/oembed?
format=json&url=http://www.dailymotion.com/embed/video/$imgid"));
$video_cek['baslik']=$hash[0]['title'];
I cant find where is the problem.Thanks
The problem is you are returning JSON Format but trying to unserialize that, this should work:
$imgid = $video_cek["embed"];
$hash = json_decode(file_get_contents("http://www.dailymotion.com/services/oembed?format=json&url=http://www.dailymotion.com/embed/video/$imgid"), true);
$video_cek['baslik']= $hash['title'];
you get a json response, so use json_decode function to Takes a JSON encoded string and converts it into a PHP variable.
like:
$array = json_decode($hash, true);
echo $array['title'];
or
$array = json_decode($hash);
echo $array->title;

Categories