根据https://www.tutorialspoint.com/php/php_constants.htm,通过使用define()函数和一个值来定义正常的配售者:
define('TEST', 123);
我认为,如果有一种方法可以定义一个内部带有函数的常量,那将是有趣而有用的:
define ('ME', function($test){
if($test == true){
return "Whats up";
}else{
return "whats down";
}
});
那我也许可以做这样的事情?
if($I_Said === ME($val)){
do something;
}
有这种方法吗?
答案 0 :(得分:3)
呼叫方在以下方面没有语法或其他重要区别:
Option Explicit
Public Sub GettingURL()
Dim c As Long, u As Long
Application.ScreenUpdating = False
With CreateObject("InternetExplorer.Application")
.Visible = True
.navigate "https://baidu.com/s?wd=" & Sheets("Data").Cells(1, 2).Text
While .Busy Or .readyState < 4: DoEvents: Wend
With .document.querySelectorAll("#content_left h3 [href]")
c = 3
For u = 0 To 4 ' Application.Min(8, .Length - 1)
Sheets("Data").Cells(c, 1) = .Item(u)
c = c + 1
Next
End With
.Quit
End With
Application.ScreenUpdating = True
End Sub
所以,只要这样做。