Hi all,
I need to test a IP for a PTR record and display the outcome.
The problem i have is i need to test with 2 vars.
$host = the ip
$hostmask = the hostmask
How do i use 2 vars in one function so i can call it like:
test_ptr($host, $hostmask)
Ive tested this but cant seem to get it to work.
code below. Thanks in advance
function test_ptr($host) {
if (strlen(gethostbyaddr($host))==
strlen(gethostbyname("$hostmask"))) {
$emsg = " !!Couldent find PTR Record!!";
}
} 5 5251 ea********@gmail.com wrote:
Hi all,
I need to test a IP for a PTR record and display the outcome.
The problem i have is i need to test with 2 vars.
$host = the ip
$hostmask = the hostmask
How do i use 2 vars in one function so i can call it like:
test_ptr($host, $hostmask)
Ive tested this but cant seem to get it to work.
code below. Thanks in advance
function test_ptr($host) {
if (strlen(gethostbyaddr($host))==
strlen(gethostbyname("$hostmask"))) {
$emsg = " !!Couldent find PTR Record!!";
}
}
I'm not exactly sure what you're trying to do, but probably:
function test_ptr($ip,$hostname){
return (trim($ip)==trim(gethostbyname($hostname)));
}
Or, alternatively, since you seem to want an error message:
function test_ptr($ip,$hostname){
$return = (bool)(trim($ip)==trim(gethostbyname($hostname)));
if(!$return) trigger_error("{$hostname}'s ip is not {$ip}");
return $return;
}
Grtz,
--
Rik Wasmus
Rik wrote:
ea********@gmail.com wrote:
>Hi all,
I need to test a IP for a PTR record and display the outcome.
The problem i have is i need to test with 2 vars.
$host = the ip $hostmask = the hostmask
How do i use 2 vars in one function so i can call it like:
test_ptr($host, $hostmask)
Ive tested this but cant seem to get it to work.
code below. Thanks in advance
function test_ptr($host) { if (strlen(gethostbyaddr($host))== strlen(gethostbyname("$hostmask"))) { $emsg = " !!Couldent find PTR Record!!"; } }
I'm not exactly sure what you're trying to do, but probably:
function test_ptr($ip,$hostname){
return (trim($ip)==trim(gethostbyname($hostname)));
}
Or, alternatively, since you seem to want an error message:
function test_ptr($ip,$hostname){
$return = (bool)(trim($ip)==trim(gethostbyname($hostname)));
if(!$return) trigger_error("{$hostname}'s ip is not {$ip}");
return $return;
}
Grtz,
I have it working now but thanks for the response! I see how your script
works, didn't think of doing it that way!
Ps. What does the (bool) do exactly (im new to php)
Luke - ea********@gmail.com wrote:
Rik wrote:
ea********@gmail.com wrote:
Hi all,
>
I need to test a IP for a PTR record and display the outcome.
>
The problem i have is i need to test with 2 vars.
>
$host = the ip
$hostmask = the hostmask
>
How do i use 2 vars in one function so i can call it like:
>
test_ptr($host, $hostmask)
>
Ive tested this but cant seem to get it to work.
>
code below. Thanks in advance
>
function test_ptr($host) {
if (strlen(gethostbyaddr($host))==
strlen(gethostbyname("$hostmask"))) {
$emsg = " !!Couldent find PTR Record!!";
}
}
I'm not exactly sure what you're trying to do, but probably:
function test_ptr($ip,$hostname){
return (trim($ip)==trim(gethostbyname($hostname)));
}
Or, alternatively, since you seem to want an error message:
function test_ptr($ip,$hostname){
$return = (bool)(trim($ip)==trim(gethostbyname($hostname)));
if(!$return) trigger_error("{$hostname}'s ip is not {$ip}");
return $return;
}
Grtz,
I have it working now but thanks for the response! I see how your
script works, didn't think of doing it that way!
Ps. What does the (bool) do exactly (im new to php)
It's a type cast that forces the variable to be evaluated as a boolean.
More about type casting can be found here: http://php.net/language.types.type-j...es.typecasting
--
Kim André Akerĝ
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Kim André Akerĝ wrote:
Luke - ea********@gmail.com wrote:
>Rik wrote:
>>ea********@gmail.com wrote: Hi all,
I need to test a IP for a PTR record and display the outcome.
The problem i have is i need to test with 2 vars.
$host = the ip $hostmask = the hostmask
How do i use 2 vars in one function so i can call it like:
test_ptr($host, $hostmask)
Ive tested this but cant seem to get it to work.
code below. Thanks in advance
function test_ptr($host) { if (strlen(gethostbyaddr($host))== strlen(gethostbyname("$hostmask"))) { $emsg = " !!Couldent find PTR Record!!"; } }
I'm not exactly sure what you're trying to do, but probably:
function test_ptr($ip,$hostname){ return (trim($ip)==trim(gethostbyname($hostname))); } Or, alternatively, since you seem to want an error message: function test_ptr($ip,$hostname){ $return = (bool)(trim($ip)==trim(gethostbyname($hostname))); if(!$return) trigger_error("{$hostname}'s ip is not {$ip}"); return $return; }
Grtz,
I have it working now but thanks for the response! I see how your script works, didn't think of doing it that way!
Ps. What does the (bool) do exactly (im new to php)
It's a type cast that forces the variable to be evaluated as a
boolean. More about type casting can be found here: http://php.net/language.types.type-j...es.typecasting
Yup, it's actually somewhat useless here, as the return should already be a
bool, but for predicatbility an clearness of code I often force a certain
type of return, so I don't mess up for instance false, 0, '' etc. Better a
typecast to many then to little.
Grtz,
--
Rik Wasmus
Rik wrote:
Kim André Akerĝ wrote:
>Luke - ea********@gmail.com wrote:
>>Rik wrote: ea********@gmail.com wrote: Hi all, > I need to test a IP for a PTR record and display the outcome. > The problem i have is i need to test with 2 vars. > $host = the ip $hostmask = the hostmask > How do i use 2 vars in one function so i can call it like: > test_ptr($host, $hostmask) > Ive tested this but cant seem to get it to work. > code below. Thanks in advance > function test_ptr($host) { if (strlen(gethostbyaddr($host))== strlen(gethostbyname("$hostmask"))) { $emsg = " !!Couldent find PTR Record!!"; } } I'm not exactly sure what you're trying to do, but probably:
function test_ptr($ip,$hostname){ return (trim($ip)==trim(gethostbyname($hostname))); } Or, alternatively, since you seem to want an error message: function test_ptr($ip,$hostname){ $return = (bool)(trim($ip)==trim(gethostbyname($hostname))); if(!$return) trigger_error("{$hostname}'s ip is not {$ip}"); return $return; }
Grtz, I have it working now but thanks for the response! I see how your script works, didn't think of doing it that way!
Ps. What does the (bool) do exactly (im new to php)
It's a type cast that forces the variable to be evaluated as a boolean. More about type casting can be found here: http://php.net/language.types.type-j...es.typecasting
Yup, it's actually somewhat useless here, as the return should already be a
bool, but for predicatbility an clearness of code I often force a certain
type of return, so I don't mess up for instance false, 0, '' etc. Better a
typecast to many then to little.
Grtz,
Thanks all, been a great help! :) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mike MacSween |
last post by:
rst.eof = true and rst.bof = true
or
rst.movelast
rst.recordcount = 0
?
|
by: dipesh |
last post by:
I have a web application that I would like to test using microsoft ACT.
When I want to record the sequence of web pages using "record a test" option
I get an error on typing the URL of my web...
|
by: mobiletornado |
last post by:
I am using visual studio .net 2003 enterprize architect.
My application test center is version 1.0.536
I am runnign window xp home edition.
I have stated a new test.
I chose to record a new test...
|
by: Michael B. Trausch |
last post by:
Alright, I seem to be at a loss for what I am looking for, and I am not
even really all that sure if it is possible or not. I found the 'pdb'
debugger, but I was wondering if there was something...
|
by: Jay Tee |
last post by:
Hi,
I have some code that does, essentially, the following:
- gather information on tens of thousands of items (in this case, jobs
running on a
compute cluster)
- store the information as a...
|
by: Helena666 |
last post by:
Hi
Its been a while since I have built a database using access and vba and am a bit rusty. I am using a command button on a form to write a record to a table, using an append query. However I need...
|
by: emily224 |
last post by:
Hello,
I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
|
by: emily224 |
last post by:
Hello,
I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
|
by: sathyguy |
last post by:
when i type the below in my RHEL AS 4's Firefox 1.5
http://appsworld.ncc.com:7777/forms/...&form=test.fmx
iam getting the below error...
The requested URL /forms/frmservlet was not found on...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |