Reputation: 23
I'm new to php so pardon the ignorance
I'm trying to include a php variable, it is and is not working.
$currentdata = file_get_contents("http://www.abr.business.gov.au/abnDetails.aspx?abn=$abn");
This works with $abn being the variable being passed from earlier being set.
$abntypedata = '/d$abn&ResultListURL=">(.+?)</'; This does not work.
$abntypedata = '/d33051775556&ResultListURL=">(.+?)</'; This does.
I need to be able to use the variable $abn to insert that number as it will be user defined. Why is this not working?
Upvotes: 1
Views: 185
Reputation: 16297
Try adding Double Quotes around the string " not ' that should render the variables other wise do this:
$abntypedata = '/d'.$abn.'&ResultListURL=">(.+?)</';
Upvotes: 0
Reputation: 5645
Php is perticular about the quotations. You have to use double quotes to include variables:
$abntypedata = "/d$abn&ResultListURL=\">(.+?)</"; This works
or
$abntypedata = '/d'.$abn.'&ResultListURL=">(.+?)</'; This works
Upvotes: 1
Reputation: 33749
You can't use inline variables like that in single-quoted strings.
$abntypedata = "/d$abn&ResultListURL=\">(.+?)</";
Upvotes: 1
Reputation: 21191
Variable substitution does not occur with single quotes. Change those to double quotes and should work.
EDIT: FYI, here's the PHP manual for strings in PHP. It's useful to know what the various types of strings are: http://www.php.net/manual/en/language.types.string.php
Upvotes: 4