看下面的代码,我看到构造函数正在返回一个值.我认为构造函数只返回对象.有人能告诉我我错过了什么吗?
public function __construct($username = null, $password = null){
$urlLogin = "{$this->apiHost}/login/$username";
$postData = sprintf("api_type=json&user=%s&passwd=%s",
$username,
$password);
$response = $this->runCurl($urlLogin, $postData);
if (count($response->json->errors) > 0){
return "login error";
} else {
$this->modHash = $response->json->data->modhash;
$this->session = $response->json->data->cookie;
return $this->modHash;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在查看似乎声明一个需要调用运行的函数的代码.此函数在匿名函数中声明.这是不是意味着该块之外的任何东西都无法访问该函数?
(function () {
var _d = vjo.dsf.EventDispatcher;
var _r = vjo.Registry;
function $1(p0) {
return function (event) {
return this.onSubmit(p0, event);
};
};
})();
Run Code Online (Sandbox Code Playgroud)
为什么有人会这样做?我不确定$此代码中的目的/相关性.
有人能告诉我这个php语句中的条件是什么吗?
return $node->type == 'article' ? mymodule_page_article($node) : mymodule_page_story($node);
Run Code Online (Sandbox Code Playgroud)
我很抱歉,如果这不是一个问这么简单的问题的地方,但我发现很难查找特定的代码结构(特别是当我不知道它的名字时).
在以下代码中,抛出TypeError: string is not a function第30行var myColour = new colour(255,255,255);.任何人都可以看到代码有什么问题.非常感谢.
var bodies = [];
var orbits = [];
var colours = [
new colour(45, 45, 45),
new colour(255, 0, 0),
new colour(0, 157, 255),
new colour(77, 250, 81),
new colour(255, 247, 0)
];
function colour(red, green, blue)
{
this.red = red;
this.green = green;
this.blue = blue;
};
window.onload = function() {
var c = document.getElementById("theCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(95,50,40,0,2*Math.PI);
ctx.stroke();
for (var colour …Run Code Online (Sandbox Code Playgroud) 我可能会离开这里,但是看看下面的调试输出,我可以看到line.value引用相同的字符串name.value(id = 70).这两个字符串只有不同之处.count.什么样的代码会输出类似的结果?这也是优化的结果吗?(如果这是一个有点愚蠢/不恰当的问题,请提前抱歉).

在下面的示例中,this []在类中用于从类instant的某处获取值.这个值存储在哪里?是否可能是[]运算符被重载或者这只是我不熟悉的c#语法?
public class MyUserSettings : ApplicationSettingsBase
{
[UserScopedSetting()]
[DefaultSettingValue("white")]
public Color BackgroundColor
{
get
{
return ((Color)this["BackgroundColor"]);
}
set
{
this["BackgroundColor"] = (Color)value;
}
}
}
Run Code Online (Sandbox Code Playgroud) 有人能告诉我this.onSubmit在下面的代码中指的是什么对象吗?
(function () {
var _d = vjo.dsf.EventDispatcher;
var _r = vjo.Registry;
function $1(p0) {
return function (event) {
return this.onSubmit(p0, event);
};
};
})();
Run Code Online (Sandbox Code Playgroud)
如果没有足够的上下文附加到这个例子,我道歉.
谁能告诉我 - >运营商会访问/呼叫什么?在这方面:
$query = db_select('date_formats', 'd')->extend('PagerDefault');
Run Code Online (Sandbox Code Playgroud)
它是否将一类PagerDefault分配给&查询或访问属性或嵌套函数或什么?我只是在猜测.谢谢.
看下面的代码,是否theme[sprite].img嵌套在里面result[definition].data(如同theme[sprite].img里面theme[sprite])以及.img成为自己的元素result[definition]?
result[definition].data = theme[sprite];
result[definition].img = theme[sprite].img;
Run Code Online (Sandbox Code Playgroud)
如果是这种情况,如果result[definition].data.img被删除会发生什么,那还会删除result[definition].img甚至theme[sprite].img吗?
谢谢.
假设外部类中有一个嵌套类; 这个嵌套类可以在其自身内实例化外部类的实例吗?
如果外部类在其自身内实例化一个内部类的实例,而该实例又在内部类中实例化外部类的实例,这是否会导致无限递归?
在审查代码时,我在评估中遇到了一些if使用!后跟 an 的语句!=,例如
if (!(fs.ReadByte() != (byte)'D' ||
fs.ReadByte() != (byte)'I' ||
fs.ReadByte() != (byte)'C' ||
fs.ReadByte() != (byte)'M'))
{
Console.WriteLine("Not a DCM");
return;
}
Run Code Online (Sandbox Code Playgroud)
是否有任何理由使用双重否定来评估正面,例如
if ((fs.ReadByte() == (byte)'D' ||
fs.ReadByte() == (byte)'I' ||
fs.ReadByte() == (byte)'C' ||
fs.ReadByte() == (byte)'M'))
{
Console.WriteLine("Not a DCM");
return;
}
Run Code Online (Sandbox Code Playgroud)
谢谢
阅读事件描述和msdn示例我可以看到事件订阅方式的差异.有时事件处理程序"按原样"传递,有时它们通过使用处理程序方法实例化委托来传递它们,例如
...
class Subscriber
{
private string id;
public Subscriber(string ID, Publisher pub)
{
id = ID;
// Subscribe to the event using C# 2.0 syntax
pub.RaiseCustomEvent += HandleCustomEvent;
}
// Define what actions to take when the event is raised.
void HandleCustomEvent(object sender, CustomEventArgs e)
{
Console.WriteLine(id + " received this message: {0}", e.Message);
}
}
Run Code Online (Sandbox Code Playgroud)
VS
public delegate void EventHandler1(int i);
...
public class TestClass
{
public static void Delegate1Method(int i)
{
System.Console.WriteLine(i);
}
public static …Run Code Online (Sandbox Code Playgroud)